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

This commit is contained in:
Andrea Boriero 2021-05-18 10:14:22 +02:00 committed by Sanne Grinovero
parent 75bcb6bc0c
commit e76a60cbfc
1 changed files with 3 additions and 2 deletions

View File

@ -166,6 +166,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;
@ -1721,7 +1722,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 );
@ -1947,7 +1948,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 );