[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 at lists.jboss.org
hibernate-commits at lists.jboss.org
Wed Oct 8 07:34:28 EDT 2008
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)
@@ -1595,7 +1595,7 @@
/**
* 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
@@ -1605,6 +1605,17 @@
}
/**
+ * 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)
@@ -10,11 +10,13 @@
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;
@@ -654,6 +656,34 @@
( ( 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)
@@ -416,7 +416,8 @@
// 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;
More information about the hibernate-commits
mailing list