mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
HHH-3519 : VM-based timestamps are not generated for DB2
git-svn-id: https://svn.jboss.org/repos/hibernate/core/branches/Branch_3_2@15280 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
e47cfe4269
commit
6a5d126098
@ -1585,7 +1585,7 @@ public boolean useInputStreamToInsertBlob() {
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -1594,6 +1594,17 @@ public boolean supportsParametersInInsertSelect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -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 @@ protected void postProcessInsert(AST insert) throws SemanticException, QueryExce
|
||||
( ( 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 {
|
||||
|
@ -415,11 +415,14 @@ public void testInsertWithGeneratedTimestampVersion() {
|
||||
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 @@ public void testInsertWithSelectListUsingJoins() {
|
||||
s.close();
|
||||
}
|
||||
|
||||
|
||||
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
public void testIncorrectSyntax() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user