HHH-17834 Force version increment for the correct inheritance table
This commit is contained in:
parent
d977b40598
commit
08c2a5479d
|
@ -2058,45 +2058,9 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
@Override
|
||||
public Object forceVersionIncrement(Object id, Object currentVersion, SharedSessionContractImplementor session) {
|
||||
if ( superMappingType != null ) {
|
||||
return superMappingType.getEntityPersister().forceVersionIncrement( id, currentVersion, session );
|
||||
}
|
||||
|
||||
assert getMappedTableDetails().getTableName().equals( getVersionedTableName() );
|
||||
final Object nextVersion = calculateNextVersion( id, currentVersion, session );
|
||||
|
||||
updateCoordinator.forceVersionIncrement( id, currentVersion, nextVersion, session );
|
||||
|
||||
// // todo : cache this sql...
|
||||
// String versionIncrementString = generateVersionIncrementUpdateString();
|
||||
// PreparedStatement st;
|
||||
// try {
|
||||
// st = session
|
||||
// .getJdbcCoordinator()
|
||||
// .getStatementPreparer()
|
||||
// .prepareStatement( versionIncrementString, false );
|
||||
// try {
|
||||
// getVersionType().nullSafeSet( st, nextVersion, 1, session );
|
||||
// getIdentifierType().nullSafeSet( st, id, 2, session );
|
||||
// getVersionType().nullSafeSet( st, currentVersion, 2 + getIdentifierColumnSpan(), session );
|
||||
// int rows = session.getJdbcCoordinator().getResultSetReturn().executeUpdate( st );
|
||||
// if ( rows != 1 ) {
|
||||
// throw new StaleObjectStateException( getEntityName(), id );
|
||||
// }
|
||||
// }
|
||||
// finally {
|
||||
// session.getJdbcCoordinator().getLogicalConnection().getResourceRegistry().release( st );
|
||||
// session.getJdbcCoordinator().afterStatementExecution();
|
||||
// }
|
||||
// }
|
||||
// catch (SQLException sqle) {
|
||||
// throw session.getJdbcServices().getSqlExceptionHelper().convert(
|
||||
// sqle,
|
||||
// "could not retrieve version: " +
|
||||
// MessageHelper.infoString( this, id, getFactory() ),
|
||||
// getVersionSelectString()
|
||||
// );
|
||||
// }
|
||||
|
||||
return nextVersion;
|
||||
}
|
||||
|
||||
|
@ -2106,12 +2070,8 @@ public abstract class AbstractEntityPersister
|
|||
Object currentVersion,
|
||||
boolean batching,
|
||||
SharedSessionContractImplementor session) throws HibernateException {
|
||||
if ( superMappingType != null ) {
|
||||
return superMappingType.getEntityPersister().forceVersionIncrement( id, currentVersion, session );
|
||||
}
|
||||
|
||||
assert getMappedTableDetails().getTableName().equals( getVersionedTableName() );
|
||||
final Object nextVersion = calculateNextVersion( id, currentVersion, session );
|
||||
|
||||
updateCoordinator.forceVersionIncrement( id, currentVersion, nextVersion, batching, session );
|
||||
return nextVersion;
|
||||
}
|
||||
|
@ -2148,17 +2108,6 @@ public abstract class AbstractEntityPersister
|
|||
return nextVersion;
|
||||
}
|
||||
|
||||
// private String generateVersionIncrementUpdateString() {
|
||||
// final Update update = new Update( getFactory().getJdbcServices().getDialect() ).setTableName( getTableName( 0 ) );
|
||||
// if ( getFactory().getSessionFactoryOptions().isCommentsEnabled() ) {
|
||||
// update.setComment( "forced version increment" );
|
||||
// }
|
||||
// update.addColumn( getVersionColumnName() );
|
||||
// update.addPrimaryKeyColumns( rootTableKeyColumnNames );
|
||||
// update.setVersionColumnName( getVersionColumnName() );
|
||||
// return update.toStatementString();
|
||||
// }
|
||||
|
||||
/**
|
||||
* Retrieve the version number
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
|||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
||||
import org.hibernate.internal.FilterAliasGenerator;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
|
@ -1082,6 +1083,26 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object forceVersionIncrement(Object id, Object currentVersion, SharedSessionContractImplementor session) {
|
||||
if ( getSuperMappingType() != null ) {
|
||||
return getSuperMappingType().getEntityPersister().forceVersionIncrement( id, currentVersion, session );
|
||||
}
|
||||
return super.forceVersionIncrement( id, currentVersion, session );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object forceVersionIncrement(
|
||||
Object id,
|
||||
Object currentVersion,
|
||||
boolean batching,
|
||||
SharedSessionContractImplementor session) throws HibernateException {
|
||||
if ( getSuperMappingType() != null ) {
|
||||
return getSuperMappingType().getEntityPersister().forceVersionIncrement( id, currentVersion, session );
|
||||
}
|
||||
return super.forceVersionIncrement( id, currentVersion, batching, session );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EntityVersionMapping generateVersionMapping(
|
||||
Supplier<?> templateInstanceCreator,
|
||||
|
|
Loading…
Reference in New Issue