HHH-17834 Force version increment for the correct inheritance table
This commit is contained in:
parent
fa9e87c675
commit
3bbc90fb9b
|
@ -2065,45 +2065,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;
|
||||
}
|
||||
|
||||
|
@ -2113,12 +2077,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;
|
||||
}
|
||||
|
@ -2155,17 +2115,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