HHH-5449 - Versioned HQL update might issue incorrect SQL
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20140 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
f818471115
commit
8a0a4a249c
|
@ -26,6 +26,7 @@ package org.hibernate.hql.ast;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -1116,7 +1117,7 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
||||||
eq.setFirstChild( versionPropertyNode );
|
eq.setFirstChild( versionPropertyNode );
|
||||||
|
|
||||||
AST versionIncrementNode = null;
|
AST versionIncrementNode = null;
|
||||||
if ( Date.class.isAssignableFrom( versionType.getReturnedClass() ) ) {
|
if ( isTimestampBasedVersion( versionType ) ) {
|
||||||
versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
|
versionIncrementNode = getASTFactory().create( HqlSqlTokenTypes.PARAM, "?" );
|
||||||
ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
|
ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification( versionType );
|
||||||
( ( ParameterNode ) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
|
( ( ParameterNode ) versionIncrementNode ).setHqlParameterSpecification( paramSpec );
|
||||||
|
@ -1141,6 +1142,12 @@ public class HqlSqlWalker extends HqlSqlBaseWalker implements ErrorReporter, Par
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isTimestampBasedVersion(VersionType versionType) {
|
||||||
|
final Class javaType = versionType.getReturnedClass();
|
||||||
|
return Date.class.isAssignableFrom( javaType )
|
||||||
|
|| Calendar.class.isAssignableFrom( javaType );
|
||||||
|
}
|
||||||
|
|
||||||
private AST generateVersionPropertyNode(Queryable persister) throws SemanticException {
|
private AST generateVersionPropertyNode(Queryable persister) throws SemanticException {
|
||||||
String versionPropertyName = persister.getPropertyNames()[ persister.getVersionProperty() ];
|
String versionPropertyName = persister.getPropertyNames()[ persister.getVersionProperty() ];
|
||||||
AST versionPropertyRef = getASTFactory().create( HqlSqlTokenTypes.IDENT, versionPropertyName );
|
AST versionPropertyRef = getASTFactory().create( HqlSqlTokenTypes.IDENT, versionPropertyName );
|
||||||
|
|
Loading…
Reference in New Issue