Author: gbadner
Date: 2008-10-08 07:43:20 -0400 (Wed, 08 Oct 2008)
New Revision: 15280
Modified:
core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java
core/branches/Branch_3_2/src/org/hibernate/hql/ast/HqlSqlWalker.java
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java
Log:
HHH-3519 : VM-based timestamps are not generated for DB2
Modified: core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java 2008-10-08 11:34:28
UTC (rev 15279)
+++ core/branches/Branch_3_2/src/org/hibernate/dialect/Dialect.java 2008-10-08 11:43:20
UTC (rev 15280)
@@ -1585,7 +1585,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
@@ -1595,6 +1595,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/src/org/hibernate/hql/ast/HqlSqlWalker.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/hql/ast/HqlSqlWalker.java 2008-10-08
11:34:28 UTC (rev 15279)
+++ core/branches/Branch_3_2/src/org/hibernate/hql/ast/HqlSqlWalker.java 2008-10-08
11:43:20 UTC (rev 15280)
@@ -15,6 +15,7 @@
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;
@@ -666,6 +667,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/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
---
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2008-10-08
11:34:28 UTC (rev 15279)
+++
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2008-10-08
11:43:20 UTC (rev 15280)
@@ -415,11 +415,14 @@
reportSkip( "bulk id generation not supported", "test bulk inserts with
generated id and generated timestamp");
return;
}
+
// 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() ) {
- reportSkip( "dialect does not support parameter in INSERT ... SELECT",
"test bulk inserts with generated id and generated timestamp");
+ if ( !getDialect().supportsParametersInInsertSelect() &&
+ !getDialect().supportsCastedParametersInInsertSelect() ) {
+ reportSkip( "dialect does not support parameter in INSERT ... SELECT",
+ "test bulk inserts with generated id and generated timestamp");
return;
}
@@ -471,7 +474,6 @@
s.close();
}
-
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void testIncorrectSyntax() {
Show replies by date