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 2a571aeb40
commit 1b50cfaea1
1 changed files with 3 additions and 2 deletions

View File

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