Java Mailing List Archive

http://www.gg3721.com/

Home » Hibernate Commits List »

[hibernate-commits] Hibernate SVN: r15279 - in
 core/branches/Branch_3_2_4_SP1_CP: src/org/hibernate/hql/ast
 and 1 other directories.

hibernate-commits

2008-10-08


Author LoginPost Reply
Author: gbadner
Date: 2008-10-08 07:34:28 -0400 (Wed, 08 Oct 2008)
New Revision: 15279

Modified:
 core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
 core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java
 core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManipulationTest.java
Log:
JBPAPP-949 HHH-3519 : VM-based timestamps are not generated for DB2


Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java  2008-10-08 09:13:49 UTC (rev 15278)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Dialect.java  2008-10-08 11:34:28 UTC (rev 15279)
@@(protected) @@

 /**
  * Does this dialect support parameters within the select clause of
-   * INSERT ... SELECT ... statements?
+   * INSERT ... SELECT ... ? ... statements?
  *
  * @return True if this is supported; false otherwise.
  * @since 3.2
@@(protected) @@
 }

 /**
+   * Does this dialect support casted parameters within the select clause of
+   * INSERT ... SELECT ... cast( ? as <type> ) statements?
+   *
+   * @return True if this is supported; false otherwise.
+   * @since 3.2
+   */
+  public boolean supportsCastedParametersInInsertSelect() {
+    return true;
+  }
+
+  /**
  * Does this dialect support asking the result set its positioning
  * information on forward only cursors. Specifically, in the case of
  * scrolling fetches, Hibernate needs to use

Modified: core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java  2008-10-08 09:13:49 UTC (rev 15278)
+++ core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/hql/ast/HqlSqlWalker.java  2008-10-08 11:34:28 UTC (rev 15279)
@@(protected) @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Arrays;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.QueryException;
import org.hibernate.HibernateException;
+import org.hibernate.AssertionFailure;
import org.hibernate.engine.JoinSequence;
import org.hibernate.engine.ParameterBinder;
import org.hibernate.engine.SessionFactoryImplementor;
@@(protected) @@
       ( ( ParameterNode ) versionValueNode ).setHqlParameterSpecification( paramSpec );
       parameters.add( 0, paramSpec );
     }
+      else if ( sessionFactoryHelper.getFactory().getDialect().supportsCastedParametersInInsertSelect() ) {
+        int sqlTypes[] = versionType.sqlTypes( sessionFactoryHelper.getFactory() );
+        if ( sqlTypes == null || sqlTypes.length == 0 ) {
+          throw new AssertionFailure( versionType.getClass() + "sqlTypes() returns null or empty array" );
+        }
+        if ( sqlTypes.length > 1 ) {
+          throw new UnsupportedOperationException( versionType.getClass() +
+              ".sqlTypes() returns > 1 element; only single-valued versions are allowed." );
+        }
+        MethodNode versionMethodNode = ( MethodNode ) getASTFactory().create( HqlSqlTokenTypes.METHOD_CALL, "(" );
+        AST methodIdentNode = getASTFactory().create( HqlSqlTokenTypes.IDENT, "cast" );
+        versionMethodNode.initializeMethodNode(methodIdentNode, true );
+        versionMethodNode.addChild( methodIdentNode );
+        AST castExprListNode = getASTFactory().create( HqlSqlTokenTypes.EXPR_LIST, "exprList" );
+        methodIdentNode.setNextSibling( castExprListNode );
+        AST paramNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
+        ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
+        ( ( ParameterNode ) paramNode ).setHqlParameterSpecification( paramSpec );
+        castExprListNode.addChild( paramNode );
+        paramNode.setNextSibling(
+            getASTFactory().create(
+                HqlSqlTokenTypes.IDENT,
+                sessionFactoryHelper.getFactory().getDialect().getTypeName( sqlTypes[0] ) )
+        );
+        processFunction( versionMethodNode, true );
+        versionValueNode = versionMethodNode;
+        parameters.add( 0, paramSpec );
+      }
     else {
       if ( isIntegral( versionType ) ) {
         try {

Modified: core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
--- core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManipulationTest.java  2008-10-08 09:13:49 UTC (rev 15278)
+++ core/branches/Branch_3_2_4_SP1_CP/test/org/hibernate/test/hql/BulkManipulationTest.java  2008-10-08 11:34:28 UTC (rev 15279)
@@(protected) @@
   // dialects which do not allow a parameter in the select portion of an INSERT ... SELECT statement
   // will also be problematic for this test because the timestamp here is vm-based as opposed to
   // db-based.
-    if ( !getDialect().supportsParametersInInsertSelect() ) {
+    if ( !getDialect().supportsParametersInInsertSelect() &&
+        !getDialect().supportsCastedParametersInInsertSelect() ) {
     reportSkip( "dialect does not support parameter in INSERT ... SELECT",
       "test bulk inserts with generated id and generated timestamp");
     return;

_______________________________________________
hibernate-commits mailing list
hibernate-commits@(protected)
https://lists.jboss.org/mailman/listinfo/hibernate-commits
©2008 gg3721.com - Jax Systems, LLC, U.S.A.