HHH-14616 Oprimistic Lock throws org.hibernate.exception.SQLGrammarException: could not retrieve version

(cherry picked from commit 1b50cfaea1)
This commit is contained in:
Andrea Boriero 2021-05-18 10:14:22 +02:00 committed by gbadner
parent 755f4ef6b6
commit 2f0504853a
1 changed files with 3 additions and 2 deletions

View File

@ -157,6 +157,7 @@ public abstract class AbstractEntityPersister
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
public static final String ENTITY_CLASS = "class";
public static final String VERSION_COLUMN_ALIAS = "v";
private final NavigableRole navigableRole;
@ -1652,7 +1653,7 @@ public abstract class AbstractEntityPersister
SimpleSelect select = new SimpleSelect( getFactory().getDialect() )
.setTableName( getVersionedTableName() );
if ( isVersioned() ) {
select.addColumn( versionColumnName );
select.addColumn( getVersionColumnName(), VERSION_COLUMN_ALIAS );
}
else {
select.addColumns( rootTableKeyColumnNames );
@ -1884,7 +1885,7 @@ public abstract class AbstractEntityPersister
if ( !isVersioned() ) {
return this;
}
return getVersionType().nullSafeGet( rs, getVersionColumnName(), session, null );
return getVersionType().nullSafeGet( rs, VERSION_COLUMN_ALIAS, session, null );
}
finally {
session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( rs, st );