diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java index 03ea9101a1..9629dafdcc 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java @@ -403,6 +403,7 @@ public final class FastSessionServices { return xmlFormatMapper; } + @Deprecated //This seems no longer used - cleanup? public MutationExecutorService getMutationExecutorService() { return mutationExecutorService; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java index 4082f2c81d..225e1740c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/BasicCollectionPersister.java @@ -178,7 +178,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister { return new InsertRowsCoordinatorNoOp( this ); } - return new InsertRowsCoordinatorStandard( this, rowMutationOperations ); + return new InsertRowsCoordinatorStandard( this, rowMutationOperations, getFactory().getServiceRegistry() ); } private DeleteRowsCoordinator buildDeleteRowCoordinator() { @@ -192,7 +192,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister { return new DeleteRowsCoordinatorNoOp( this ); } - return new DeleteRowsCoordinatorStandard( this, rowMutationOperations, hasPhysicalIndexColumn() ); + return new DeleteRowsCoordinatorStandard( this, rowMutationOperations, hasPhysicalIndexColumn(), getFactory().getServiceRegistry() ); } private RemoveCoordinator buildDeleteAllCoordinator() { @@ -206,7 +206,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister { return new RemoveCoordinatorNoOp( this ); } - return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation ); + return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation, getFactory().getServiceRegistry() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java index 3dfe45f42e..e909790090 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/OneToManyPersister.java @@ -106,6 +106,7 @@ public class OneToManyPersister extends AbstractCollectionPersister { private final boolean cascadeDeleteEnabled; private final boolean keyIsNullable; private final boolean keyIsUpdateable; + private final MutationExecutorService mutationExecutorService; @Deprecated(since = "6.0") public OneToManyPersister( @@ -131,6 +132,7 @@ public class OneToManyPersister extends AbstractCollectionPersister { this.updateRowsCoordinator = buildUpdateCoordinator(); this.deleteRowsCoordinator = buildDeleteCoordinator(); this.removeCoordinator = buildDeleteAllCoordinator(); + this.mutationExecutorService = creationContext.getServiceRegistry().getService( MutationExecutorService.class ); } @Override @@ -225,9 +227,6 @@ public class OneToManyPersister extends AbstractCollectionPersister { final RowMutationOperations.Restrictions updateRowRestrictions = rowMutationOperations.getUpdateRowRestrictions(); assert NullnessHelper.areAllNonNull( updateRowOperation, updateRowValues, updateRowRestrictions ); - final MutationExecutorService mutationExecutorService = getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> new BasicBatchKey( getNavigableRole() + "#INDEX" ), new MutationOperationGroupSingle( MutationType.UPDATE, this, updateRowOperation ), @@ -453,9 +452,9 @@ public class OneToManyPersister extends AbstractCollectionPersister { if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses() && getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { - return new InsertRowsCoordinatorTablePerSubclass( this, rowMutationOperations ); + return new InsertRowsCoordinatorTablePerSubclass( this, rowMutationOperations, getFactory().getServiceRegistry() ); } - return new InsertRowsCoordinatorStandard( this, rowMutationOperations ); + return new InsertRowsCoordinatorStandard( this, rowMutationOperations, getFactory().getServiceRegistry() ); } private UpdateRowsCoordinator buildUpdateCoordinator() { @@ -490,13 +489,14 @@ public class OneToManyPersister extends AbstractCollectionPersister { if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses() && getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { - return new DeleteRowsCoordinatorTablePerSubclass( this, rowMutationOperations, false ); + return new DeleteRowsCoordinatorTablePerSubclass( this, rowMutationOperations, false, getFactory().getServiceRegistry() ); } return new DeleteRowsCoordinatorStandard( this, rowMutationOperations, // never delete by index for one-to-many - false + false, + getFactory().getServiceRegistry() ); } @@ -513,9 +513,9 @@ public class OneToManyPersister extends AbstractCollectionPersister { if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses() && getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { - return new RemoveCoordinatorTablePerSubclass( this, this::buildDeleteAllOperation ); + return new RemoveCoordinatorTablePerSubclass( this, this::buildDeleteAllOperation, getFactory().getServiceRegistry() ); } - return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation ); + return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation, getFactory().getServiceRegistry() ); } private JdbcMutationOperation generateDeleteRowOperation(MutatingTableReference tableReference) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/AbstractUpdateRowsCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/AbstractUpdateRowsCoordinator.java index 4d8def8c3e..aa45df3dbb 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/AbstractUpdateRowsCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/AbstractUpdateRowsCoordinator.java @@ -7,6 +7,7 @@ package org.hibernate.persister.collection.mutation; import org.hibernate.collection.spi.PersistentCollection; +import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; @@ -18,10 +19,12 @@ import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER public abstract class AbstractUpdateRowsCoordinator implements UpdateRowsCoordinator { private final CollectionMutationTarget mutationTarget; private final SessionFactoryImplementor sessionFactory; + protected final MutationExecutorService mutationExecutorService; public AbstractUpdateRowsCoordinator(CollectionMutationTarget mutationTarget, SessionFactoryImplementor sessionFactory) { this.mutationTarget = mutationTarget; this.sessionFactory = sessionFactory; + this.mutationExecutorService = sessionFactory.getServiceRegistry().getService( MutationExecutorService.class ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorStandard.java index 100743c57d..64ad368596 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorStandard.java @@ -12,11 +12,11 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.MutationExecutor; -import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.jdbc.JdbcMutationOperation; @@ -33,18 +33,21 @@ public class DeleteRowsCoordinatorStandard implements DeleteRowsCoordinator { private final boolean deleteByIndex; private final BasicBatchKey batchKey; + private final MutationExecutorService mutationExecutorService; private MutationOperationGroupSingle operationGroup; public DeleteRowsCoordinatorStandard( CollectionMutationTarget mutationTarget, RowMutationOperations rowMutationOperations, - boolean deleteByIndex) { + boolean deleteByIndex, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.rowMutationOperations = rowMutationOperations; this.deleteByIndex = deleteByIndex; this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#DELETE" ); + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -66,10 +69,6 @@ public class DeleteRowsCoordinatorStandard implements DeleteRowsCoordinator { ); } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> batchKey, operationGroup, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorTablePerSubclass.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorTablePerSubclass.java index 2f889cadef..89d6e9a8f0 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorTablePerSubclass.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/DeleteRowsCoordinatorTablePerSubclass.java @@ -21,6 +21,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.jdbc.JdbcMutationOperation; @@ -37,15 +38,18 @@ public class DeleteRowsCoordinatorTablePerSubclass implements DeleteRowsCoordina private final boolean deleteByIndex; private final SubclassEntry[] subclassEntries; + private final MutationExecutorService mutationExecutorService; public DeleteRowsCoordinatorTablePerSubclass( OneToManyPersister mutationTarget, RowMutationOperations rowMutationOperations, - boolean deleteByIndex) { + boolean deleteByIndex, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.rowMutationOperations = rowMutationOperations; this.deleteByIndex = deleteByIndex; this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()]; + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -63,11 +67,6 @@ public class DeleteRowsCoordinatorTablePerSubclass implements DeleteRowsCoordina ); } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); - final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorStandard.java index 61c11e61c1..f535308569 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorStandard.java @@ -12,11 +12,11 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.MutationExecutor; -import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.jdbc.JdbcMutationOperation; @@ -32,16 +32,19 @@ public class InsertRowsCoordinatorStandard implements InsertRowsCoordinator { private final RowMutationOperations rowMutationOperations; private final BasicBatchKey batchKey; + private final MutationExecutorService mutationExecutorService; private MutationOperationGroupSingle operationGroup; public InsertRowsCoordinatorStandard( CollectionMutationTarget mutationTarget, - RowMutationOperations rowMutationOperations) { + RowMutationOperations rowMutationOperations, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.rowMutationOperations = rowMutationOperations; this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#INSERT" ); + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -75,10 +78,6 @@ public class InsertRowsCoordinatorStandard implements InsertRowsCoordinator { final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> batchKey, operationGroup, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorTablePerSubclass.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorTablePerSubclass.java index 68fbe928e6..54f7cd1166 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorTablePerSubclass.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/InsertRowsCoordinatorTablePerSubclass.java @@ -19,6 +19,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.jdbc.JdbcMutationOperation; @@ -34,13 +35,16 @@ public class InsertRowsCoordinatorTablePerSubclass implements InsertRowsCoordina private final RowMutationOperations rowMutationOperations; private final SubclassEntry[] subclassEntries; + private final MutationExecutorService mutationExecutorService; public InsertRowsCoordinatorTablePerSubclass( OneToManyPersister mutationTarget, - RowMutationOperations rowMutationOperations) { + RowMutationOperations rowMutationOperations, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.rowMutationOperations = rowMutationOperations; this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()]; + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -70,11 +74,6 @@ public class InsertRowsCoordinatorTablePerSubclass implements InsertRowsCoordina final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); - final Iterator entries = collection.entries( collectionDescriptor ); collection.preInsert( collectionDescriptor ); if ( !entries.hasNext() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorStandard.java index b3c64ae466..552da59fd1 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorStandard.java @@ -12,6 +12,7 @@ import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.ast.MutatingTableReference; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; @@ -30,6 +31,7 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator { private final CollectionMutationTarget mutationTarget; private final OperationProducer operationProducer; private final BasicBatchKey batchKey; + private final MutationExecutorService mutationExecutorService; private MutationOperationGroupSingle operationGroup; @@ -41,11 +43,13 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator { */ public RemoveCoordinatorStandard( CollectionMutationTarget mutationTarget, - OperationProducer operationProducer) { + OperationProducer operationProducer, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.operationProducer = operationProducer; this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#REMOVE" ); + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -84,10 +88,6 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator { operationGroup = buildOperationGroup(); } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> batchKey, operationGroup, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorTablePerSubclass.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorTablePerSubclass.java index 8c85af8366..1ee0b4de94 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorTablePerSubclass.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/RemoveCoordinatorTablePerSubclass.java @@ -15,6 +15,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.service.ServiceRegistry; import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.ast.MutatingTableReference; import org.hibernate.sql.model.internal.MutationOperationGroupSingle; @@ -29,6 +30,7 @@ import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator { private final OneToManyPersister mutationTarget; private final OperationProducer operationProducer; + private final MutationExecutorService mutationExecutorService; private MutationOperationGroupSingle[] operationGroups; @@ -40,9 +42,11 @@ public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator { */ public RemoveCoordinatorTablePerSubclass( OneToManyPersister mutationTarget, - OperationProducer operationProducer) { + OperationProducer operationProducer, + ServiceRegistry serviceRegistry) { this.mutationTarget = mutationTarget; this.operationProducer = operationProducer; + this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class ); } @Override @@ -76,10 +80,6 @@ public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator { operationGroups = this.operationGroups = buildOperationGroups(); } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final ForeignKeyDescriptor fkDescriptor = mutationTarget.getTargetPart().getKeyDescriptor(); for ( MutationOperationGroupSingle operationGroup : operationGroups ) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorOneToMany.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorOneToMany.java index e3b9d05686..1b6febe9ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorOneToMany.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorOneToMany.java @@ -12,8 +12,6 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.MutationExecutor; -import org.hibernate.engine.jdbc.mutation.ParameterUsage; -import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; @@ -61,10 +59,6 @@ public class UpdateRowsCoordinatorOneToMany extends AbstractUpdateRowsCoordinato } final MutationOperationGroupSingle operationGroup = resolveDeleteGroup(); - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-DELETE" ), operationGroup, @@ -122,10 +116,6 @@ public class UpdateRowsCoordinatorOneToMany extends AbstractUpdateRowsCoordinato } final MutationOperationGroupSingle operationGroup = resolveInsertGroup(); - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-INSERT" ), operationGroup, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorStandard.java index 33292a2e3f..9ff1d1ad5b 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorStandard.java @@ -13,8 +13,6 @@ import java.util.List; import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.mutation.MutationExecutor; -import org.hibernate.engine.jdbc.mutation.ParameterUsage; -import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; @@ -32,8 +30,8 @@ import org.hibernate.sql.model.jdbc.JdbcMutationOperation; * @author Steve Ebersole */ public class UpdateRowsCoordinatorStandard extends AbstractUpdateRowsCoordinator implements UpdateRowsCoordinator { - private final RowMutationOperations rowMutationOperations; + private final RowMutationOperations rowMutationOperations; private AbstractMutationOperationGroup operationGroup; public UpdateRowsCoordinatorStandard( @@ -48,10 +46,6 @@ public class UpdateRowsCoordinatorStandard extends AbstractUpdateRowsCoordinator protected int doUpdate(Object key, PersistentCollection collection, SharedSessionContractImplementor session) { final AbstractMutationOperationGroup operationGroup = getOperationGroup(); - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE" ), operationGroup, diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorTablePerSubclass.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorTablePerSubclass.java index e83b209f24..e70ee2719b 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorTablePerSubclass.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/mutation/UpdateRowsCoordinatorTablePerSubclass.java @@ -12,7 +12,6 @@ import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.spi.BatchKeyAccess; -import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; @@ -64,11 +63,6 @@ public class UpdateRowsCoordinatorTablePerSubclass extends AbstractUpdateRowsCoo return; } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); - final MutationExecutor[] executors = new MutationExecutor[deleteSubclassEntries.length]; try { int entryPosition = -1; @@ -157,11 +151,6 @@ public class UpdateRowsCoordinatorTablePerSubclass extends AbstractUpdateRowsCoo return -1; } - final MutationExecutorService mutationExecutorService = session - .getFactory() - .getFastSessionServices() - .getMutationExecutorService(); - final MutationExecutor[] executors = new MutationExecutor[insertSubclassEntries.length]; try { int entryPosition = -1; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java index fce4d1d4e9..e25a30a6ef 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/AbstractMutationCoordinator.java @@ -15,6 +15,7 @@ import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.internal.NoBatchKeyAccess; import org.hibernate.engine.jdbc.mutation.spi.BatchKeyAccess; +import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.generator.OnExecutionGenerator; @@ -43,12 +44,16 @@ import static org.hibernate.internal.util.collections.CollectionHelper.arrayList */ @Internal public abstract class AbstractMutationCoordinator { - private final AbstractEntityPersister entityPersister; - private final SessionFactoryImplementor factory; + protected final AbstractEntityPersister entityPersister; + protected final SessionFactoryImplementor factory; + protected final MutationExecutorService mutationExecutorService; + protected final Dialect dialect; public AbstractMutationCoordinator(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { this.entityPersister = entityPersister; this.factory = factory; + dialect = factory.getJdbcServices().getDialect(); + this.mutationExecutorService = factory.getServiceRegistry().getService( MutationExecutorService.class ); } protected AbstractEntityPersister entityPersister() { @@ -60,7 +65,7 @@ public abstract class AbstractMutationCoordinator { } protected Dialect dialect() { - return factory().getJdbcServices().getDialect(); + return dialect; } protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) { diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java index e7f28996b6..4994acb037 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/DeleteCoordinator.java @@ -131,9 +131,7 @@ public class DeleteCoordinator extends AbstractMutationCoordinator { } private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group) { - return session.getFactory() - .getServiceRegistry() - .getService( MutationExecutorService.class ) + return mutationExecutorService .createExecutor( resolveBatchKeyAccess( false, session ), group, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java index dc25828cd0..baa97dd5c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/InsertCoordinator.java @@ -17,7 +17,6 @@ import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.TableInclusionChecker; -import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.generator.BeforeExecutionGenerator; @@ -304,9 +303,7 @@ public class InsertCoordinator extends AbstractMutationCoordinator { } private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { - return session.getFactory() - .getServiceRegistry() - .getService( MutationExecutorService.class ) + return mutationExecutorService .createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java index aca46a7aa6..65ab0ead47 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/mutation/UpdateCoordinatorStandard.java @@ -989,16 +989,12 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple } private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { - return session.getSessionFactory() - .getFastSessionServices() - .getMutationExecutorService() + return mutationExecutorService .createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session ); } private MutationExecutor updateVersionExecutor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { - return session.getSessionFactory() - .getFastSessionServices() - .getMutationExecutorService() + return mutationExecutorService .createExecutor( resolveUpdateVersionBatchKeyAccess( dynamicUpdate, session ), group, session ); }