HHH-16877 Efficient lookup of MutationExecutorService

This commit is contained in:
Sanne Grinovero 2023-06-29 22:00:34 +01:00 committed by Sanne Grinovero
parent afd3bee28e
commit abc4f9f356
17 changed files with 59 additions and 90 deletions

View File

@ -403,6 +403,7 @@ public final class FastSessionServices {
return xmlFormatMapper; return xmlFormatMapper;
} }
@Deprecated //This seems no longer used - cleanup?
public MutationExecutorService getMutationExecutorService() { public MutationExecutorService getMutationExecutorService() {
return mutationExecutorService; return mutationExecutorService;
} }

View File

@ -178,7 +178,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
return new InsertRowsCoordinatorNoOp( this ); return new InsertRowsCoordinatorNoOp( this );
} }
return new InsertRowsCoordinatorStandard( this, rowMutationOperations ); return new InsertRowsCoordinatorStandard( this, rowMutationOperations, getFactory().getServiceRegistry() );
} }
private DeleteRowsCoordinator buildDeleteRowCoordinator() { private DeleteRowsCoordinator buildDeleteRowCoordinator() {
@ -192,7 +192,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
return new DeleteRowsCoordinatorNoOp( this ); return new DeleteRowsCoordinatorNoOp( this );
} }
return new DeleteRowsCoordinatorStandard( this, rowMutationOperations, hasPhysicalIndexColumn() ); return new DeleteRowsCoordinatorStandard( this, rowMutationOperations, hasPhysicalIndexColumn(), getFactory().getServiceRegistry() );
} }
private RemoveCoordinator buildDeleteAllCoordinator() { private RemoveCoordinator buildDeleteAllCoordinator() {
@ -206,7 +206,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
return new RemoveCoordinatorNoOp( this ); return new RemoveCoordinatorNoOp( this );
} }
return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation ); return new RemoveCoordinatorStandard( this, this::buildDeleteAllOperation, getFactory().getServiceRegistry() );
} }

View File

@ -106,6 +106,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
private final boolean cascadeDeleteEnabled; private final boolean cascadeDeleteEnabled;
private final boolean keyIsNullable; private final boolean keyIsNullable;
private final boolean keyIsUpdateable; private final boolean keyIsUpdateable;
private final MutationExecutorService mutationExecutorService;
@Deprecated(since = "6.0") @Deprecated(since = "6.0")
public OneToManyPersister( public OneToManyPersister(
@ -131,6 +132,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
this.updateRowsCoordinator = buildUpdateCoordinator(); this.updateRowsCoordinator = buildUpdateCoordinator();
this.deleteRowsCoordinator = buildDeleteCoordinator(); this.deleteRowsCoordinator = buildDeleteCoordinator();
this.removeCoordinator = buildDeleteAllCoordinator(); this.removeCoordinator = buildDeleteAllCoordinator();
this.mutationExecutorService = creationContext.getServiceRegistry().getService( MutationExecutorService.class );
} }
@Override @Override
@ -225,9 +227,6 @@ public class OneToManyPersister extends AbstractCollectionPersister {
final RowMutationOperations.Restrictions updateRowRestrictions = rowMutationOperations.getUpdateRowRestrictions(); final RowMutationOperations.Restrictions updateRowRestrictions = rowMutationOperations.getUpdateRowRestrictions();
assert NullnessHelper.areAllNonNull( updateRowOperation, updateRowValues, updateRowRestrictions ); assert NullnessHelper.areAllNonNull( updateRowOperation, updateRowValues, updateRowRestrictions );
final MutationExecutorService mutationExecutorService = getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> new BasicBatchKey( getNavigableRole() + "#INDEX" ), () -> new BasicBatchKey( getNavigableRole() + "#INDEX" ),
new MutationOperationGroupSingle( MutationType.UPDATE, this, updateRowOperation ), new MutationOperationGroupSingle( MutationType.UPDATE, this, updateRowOperation ),
@ -453,9 +452,9 @@ public class OneToManyPersister extends AbstractCollectionPersister {
if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses() if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses()
&& getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { && 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() { private UpdateRowsCoordinator buildUpdateCoordinator() {
@ -490,13 +489,14 @@ public class OneToManyPersister extends AbstractCollectionPersister {
if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses() if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses()
&& getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { && getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) {
return new DeleteRowsCoordinatorTablePerSubclass( this, rowMutationOperations, false ); return new DeleteRowsCoordinatorTablePerSubclass( this, rowMutationOperations, false, getFactory().getServiceRegistry() );
} }
return new DeleteRowsCoordinatorStandard( return new DeleteRowsCoordinatorStandard(
this, this,
rowMutationOperations, rowMutationOperations,
// never delete by index for one-to-many // 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() if ( getElementPersisterInternal() != null && getElementPersisterInternal().hasSubclasses()
&& getElementPersisterInternal() instanceof UnionSubclassEntityPersister ) { && 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) { private JdbcMutationOperation generateDeleteRowOperation(MutatingTableReference tableReference) {

View File

@ -7,6 +7,7 @@
package org.hibernate.persister.collection.mutation; package org.hibernate.persister.collection.mutation;
import org.hibernate.collection.spi.PersistentCollection; 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.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; 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 { public abstract class AbstractUpdateRowsCoordinator implements UpdateRowsCoordinator {
private final CollectionMutationTarget mutationTarget; private final CollectionMutationTarget mutationTarget;
private final SessionFactoryImplementor sessionFactory; private final SessionFactoryImplementor sessionFactory;
protected final MutationExecutorService mutationExecutorService;
public AbstractUpdateRowsCoordinator(CollectionMutationTarget mutationTarget, SessionFactoryImplementor sessionFactory) { public AbstractUpdateRowsCoordinator(CollectionMutationTarget mutationTarget, SessionFactoryImplementor sessionFactory) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.sessionFactory = sessionFactory; this.sessionFactory = sessionFactory;
this.mutationExecutorService = sessionFactory.getServiceRegistry().getService( MutationExecutorService.class );
} }
@Override @Override

View File

@ -12,11 +12,11 @@ import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; 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.jdbc.mutation.spi.MutationExecutorService;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupSingle;
import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
@ -33,18 +33,21 @@ public class DeleteRowsCoordinatorStandard implements DeleteRowsCoordinator {
private final boolean deleteByIndex; private final boolean deleteByIndex;
private final BasicBatchKey batchKey; private final BasicBatchKey batchKey;
private final MutationExecutorService mutationExecutorService;
private MutationOperationGroupSingle operationGroup; private MutationOperationGroupSingle operationGroup;
public DeleteRowsCoordinatorStandard( public DeleteRowsCoordinatorStandard(
CollectionMutationTarget mutationTarget, CollectionMutationTarget mutationTarget,
RowMutationOperations rowMutationOperations, RowMutationOperations rowMutationOperations,
boolean deleteByIndex) { boolean deleteByIndex,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.rowMutationOperations = rowMutationOperations; this.rowMutationOperations = rowMutationOperations;
this.deleteByIndex = deleteByIndex; this.deleteByIndex = deleteByIndex;
this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#DELETE" ); this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#DELETE" );
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -66,10 +69,6 @@ public class DeleteRowsCoordinatorStandard implements DeleteRowsCoordinator {
); );
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> batchKey, () -> batchKey,
operationGroup, operationGroup,

View File

@ -21,6 +21,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.collection.OneToManyPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupSingle;
import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
@ -37,15 +38,18 @@ public class DeleteRowsCoordinatorTablePerSubclass implements DeleteRowsCoordina
private final boolean deleteByIndex; private final boolean deleteByIndex;
private final SubclassEntry[] subclassEntries; private final SubclassEntry[] subclassEntries;
private final MutationExecutorService mutationExecutorService;
public DeleteRowsCoordinatorTablePerSubclass( public DeleteRowsCoordinatorTablePerSubclass(
OneToManyPersister mutationTarget, OneToManyPersister mutationTarget,
RowMutationOperations rowMutationOperations, RowMutationOperations rowMutationOperations,
boolean deleteByIndex) { boolean deleteByIndex,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.rowMutationOperations = rowMutationOperations; this.rowMutationOperations = rowMutationOperations;
this.deleteByIndex = deleteByIndex; this.deleteByIndex = deleteByIndex;
this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()]; this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()];
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -63,11 +67,6 @@ public class DeleteRowsCoordinatorTablePerSubclass implements DeleteRowsCoordina
); );
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor();

View File

@ -12,11 +12,11 @@ import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; 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.jdbc.mutation.spi.MutationExecutorService;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupSingle;
import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
@ -32,16 +32,19 @@ public class InsertRowsCoordinatorStandard implements InsertRowsCoordinator {
private final RowMutationOperations rowMutationOperations; private final RowMutationOperations rowMutationOperations;
private final BasicBatchKey batchKey; private final BasicBatchKey batchKey;
private final MutationExecutorService mutationExecutorService;
private MutationOperationGroupSingle operationGroup; private MutationOperationGroupSingle operationGroup;
public InsertRowsCoordinatorStandard( public InsertRowsCoordinatorStandard(
CollectionMutationTarget mutationTarget, CollectionMutationTarget mutationTarget,
RowMutationOperations rowMutationOperations) { RowMutationOperations rowMutationOperations,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.rowMutationOperations = rowMutationOperations; this.rowMutationOperations = rowMutationOperations;
this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#INSERT" ); this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#INSERT" );
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -75,10 +78,6 @@ public class InsertRowsCoordinatorStandard implements InsertRowsCoordinator {
final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor();
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> batchKey, () -> batchKey,
operationGroup, operationGroup,

View File

@ -19,6 +19,7 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.collection.OneToManyPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupSingle;
import org.hibernate.sql.model.jdbc.JdbcMutationOperation; import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
@ -34,13 +35,16 @@ public class InsertRowsCoordinatorTablePerSubclass implements InsertRowsCoordina
private final RowMutationOperations rowMutationOperations; private final RowMutationOperations rowMutationOperations;
private final SubclassEntry[] subclassEntries; private final SubclassEntry[] subclassEntries;
private final MutationExecutorService mutationExecutorService;
public InsertRowsCoordinatorTablePerSubclass( public InsertRowsCoordinatorTablePerSubclass(
OneToManyPersister mutationTarget, OneToManyPersister mutationTarget,
RowMutationOperations rowMutationOperations) { RowMutationOperations rowMutationOperations,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.rowMutationOperations = rowMutationOperations; this.rowMutationOperations = rowMutationOperations;
this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()]; this.subclassEntries = new SubclassEntry[mutationTarget.getElementPersister().getRootEntityDescriptor().getSubclassEntityNames().size()];
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -70,11 +74,6 @@ public class InsertRowsCoordinatorTablePerSubclass implements InsertRowsCoordina
final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart(); final PluralAttributeMapping pluralAttribute = mutationTarget.getTargetPart();
final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor(); final CollectionPersister collectionDescriptor = pluralAttribute.getCollectionDescriptor();
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final Iterator<?> entries = collection.entries( collectionDescriptor ); final Iterator<?> entries = collection.entries( collectionDescriptor );
collection.preInsert( collectionDescriptor ); collection.preInsert( collectionDescriptor );
if ( !entries.hasNext() ) { if ( !entries.hasNext() ) {

View File

@ -12,6 +12,7 @@ import org.hibernate.engine.jdbc.mutation.MutationExecutor;
import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService; import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.ast.MutatingTableReference; import org.hibernate.sql.model.ast.MutatingTableReference;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; import org.hibernate.sql.model.internal.MutationOperationGroupSingle;
@ -30,6 +31,7 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator {
private final CollectionMutationTarget mutationTarget; private final CollectionMutationTarget mutationTarget;
private final OperationProducer operationProducer; private final OperationProducer operationProducer;
private final BasicBatchKey batchKey; private final BasicBatchKey batchKey;
private final MutationExecutorService mutationExecutorService;
private MutationOperationGroupSingle operationGroup; private MutationOperationGroupSingle operationGroup;
@ -41,11 +43,13 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator {
*/ */
public RemoveCoordinatorStandard( public RemoveCoordinatorStandard(
CollectionMutationTarget mutationTarget, CollectionMutationTarget mutationTarget,
OperationProducer operationProducer) { OperationProducer operationProducer,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.operationProducer = operationProducer; this.operationProducer = operationProducer;
this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#REMOVE" ); this.batchKey = new BasicBatchKey( mutationTarget.getRolePath() + "#REMOVE" );
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -84,10 +88,6 @@ public class RemoveCoordinatorStandard implements RemoveCoordinator {
operationGroup = buildOperationGroup(); operationGroup = buildOperationGroup();
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> batchKey, () -> batchKey,
operationGroup, operationGroup,

View File

@ -15,6 +15,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.persister.collection.OneToManyPersister; import org.hibernate.persister.collection.OneToManyPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.ast.MutatingTableReference; import org.hibernate.sql.model.ast.MutatingTableReference;
import org.hibernate.sql.model.internal.MutationOperationGroupSingle; 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 { public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator {
private final OneToManyPersister mutationTarget; private final OneToManyPersister mutationTarget;
private final OperationProducer operationProducer; private final OperationProducer operationProducer;
private final MutationExecutorService mutationExecutorService;
private MutationOperationGroupSingle[] operationGroups; private MutationOperationGroupSingle[] operationGroups;
@ -40,9 +42,11 @@ public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator {
*/ */
public RemoveCoordinatorTablePerSubclass( public RemoveCoordinatorTablePerSubclass(
OneToManyPersister mutationTarget, OneToManyPersister mutationTarget,
OperationProducer operationProducer) { OperationProducer operationProducer,
ServiceRegistry serviceRegistry) {
this.mutationTarget = mutationTarget; this.mutationTarget = mutationTarget;
this.operationProducer = operationProducer; this.operationProducer = operationProducer;
this.mutationExecutorService = serviceRegistry.getService( MutationExecutorService.class );
} }
@Override @Override
@ -76,10 +80,6 @@ public class RemoveCoordinatorTablePerSubclass implements RemoveCoordinator {
operationGroups = this.operationGroups = buildOperationGroups(); operationGroups = this.operationGroups = buildOperationGroups();
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final ForeignKeyDescriptor fkDescriptor = mutationTarget.getTargetPart().getKeyDescriptor(); final ForeignKeyDescriptor fkDescriptor = mutationTarget.getTargetPart().getKeyDescriptor();
for ( MutationOperationGroupSingle operationGroup : operationGroups ) { for ( MutationOperationGroupSingle operationGroup : operationGroups ) {

View File

@ -12,8 +12,6 @@ import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.mutation.JdbcValueBindings; import org.hibernate.engine.jdbc.mutation.JdbcValueBindings;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; 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.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
@ -61,10 +59,6 @@ public class UpdateRowsCoordinatorOneToMany extends AbstractUpdateRowsCoordinato
} }
final MutationOperationGroupSingle operationGroup = resolveDeleteGroup(); final MutationOperationGroupSingle operationGroup = resolveDeleteGroup();
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-DELETE" ), () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-DELETE" ),
operationGroup, operationGroup,
@ -122,10 +116,6 @@ public class UpdateRowsCoordinatorOneToMany extends AbstractUpdateRowsCoordinato
} }
final MutationOperationGroupSingle operationGroup = resolveInsertGroup(); final MutationOperationGroupSingle operationGroup = resolveInsertGroup();
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-INSERT" ), () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE-INSERT" ),
operationGroup, operationGroup,

View File

@ -13,8 +13,6 @@ import java.util.List;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; 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.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
@ -32,8 +30,8 @@ import org.hibernate.sql.model.jdbc.JdbcMutationOperation;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class UpdateRowsCoordinatorStandard extends AbstractUpdateRowsCoordinator implements UpdateRowsCoordinator { public class UpdateRowsCoordinatorStandard extends AbstractUpdateRowsCoordinator implements UpdateRowsCoordinator {
private final RowMutationOperations rowMutationOperations;
private final RowMutationOperations rowMutationOperations;
private AbstractMutationOperationGroup operationGroup; private AbstractMutationOperationGroup operationGroup;
public UpdateRowsCoordinatorStandard( public UpdateRowsCoordinatorStandard(
@ -48,10 +46,6 @@ public class UpdateRowsCoordinatorStandard extends AbstractUpdateRowsCoordinator
protected int doUpdate(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) { protected int doUpdate(Object key, PersistentCollection<?> collection, SharedSessionContractImplementor session) {
final AbstractMutationOperationGroup operationGroup = getOperationGroup(); final AbstractMutationOperationGroup operationGroup = getOperationGroup();
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor( final MutationExecutor mutationExecutor = mutationExecutorService.createExecutor(
() -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE" ), () -> new BasicBatchKey( getMutationTarget().getRolePath() + "#UPDATE" ),
operationGroup, operationGroup,

View File

@ -12,7 +12,6 @@ import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey; import org.hibernate.engine.jdbc.batch.internal.BasicBatchKey;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.MutationExecutor;
import org.hibernate.engine.jdbc.mutation.spi.BatchKeyAccess; 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.EntityEntry;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
@ -64,11 +63,6 @@ public class UpdateRowsCoordinatorTablePerSubclass extends AbstractUpdateRowsCoo
return; return;
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor[] executors = new MutationExecutor[deleteSubclassEntries.length]; final MutationExecutor[] executors = new MutationExecutor[deleteSubclassEntries.length];
try { try {
int entryPosition = -1; int entryPosition = -1;
@ -157,11 +151,6 @@ public class UpdateRowsCoordinatorTablePerSubclass extends AbstractUpdateRowsCoo
return -1; return -1;
} }
final MutationExecutorService mutationExecutorService = session
.getFactory()
.getFastSessionServices()
.getMutationExecutorService();
final MutationExecutor[] executors = new MutationExecutor[insertSubclassEntries.length]; final MutationExecutor[] executors = new MutationExecutor[insertSubclassEntries.length];
try { try {
int entryPosition = -1; int entryPosition = -1;

View File

@ -15,6 +15,7 @@ import org.hibernate.engine.jdbc.mutation.JdbcValueBindings;
import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.ParameterUsage;
import org.hibernate.engine.jdbc.mutation.internal.NoBatchKeyAccess; import org.hibernate.engine.jdbc.mutation.internal.NoBatchKeyAccess;
import org.hibernate.engine.jdbc.mutation.spi.BatchKeyAccess; 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.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.generator.OnExecutionGenerator; import org.hibernate.generator.OnExecutionGenerator;
@ -43,12 +44,16 @@ import static org.hibernate.internal.util.collections.CollectionHelper.arrayList
*/ */
@Internal @Internal
public abstract class AbstractMutationCoordinator { public abstract class AbstractMutationCoordinator {
private final AbstractEntityPersister entityPersister; protected final AbstractEntityPersister entityPersister;
private final SessionFactoryImplementor factory; protected final SessionFactoryImplementor factory;
protected final MutationExecutorService mutationExecutorService;
protected final Dialect dialect;
public AbstractMutationCoordinator(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public AbstractMutationCoordinator(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) {
this.entityPersister = entityPersister; this.entityPersister = entityPersister;
this.factory = factory; this.factory = factory;
dialect = factory.getJdbcServices().getDialect();
this.mutationExecutorService = factory.getServiceRegistry().getService( MutationExecutorService.class );
} }
protected AbstractEntityPersister entityPersister() { protected AbstractEntityPersister entityPersister() {
@ -60,7 +65,7 @@ public abstract class AbstractMutationCoordinator {
} }
protected Dialect dialect() { protected Dialect dialect() {
return factory().getJdbcServices().getDialect(); return dialect;
} }
protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) { protected BatchKeyAccess resolveBatchKeyAccess(boolean dynamicUpdate, SharedSessionContractImplementor session) {

View File

@ -131,9 +131,7 @@ public class DeleteCoordinator extends AbstractMutationCoordinator {
} }
private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group) { private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group) {
return session.getFactory() return mutationExecutorService
.getServiceRegistry()
.getService( MutationExecutorService.class )
.createExecutor( resolveBatchKeyAccess( false, session ), group, session ); .createExecutor( resolveBatchKeyAccess( false, session ), group, session );
} }

View File

@ -17,7 +17,6 @@ import org.hibernate.engine.jdbc.mutation.JdbcValueBindings;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.MutationExecutor;
import org.hibernate.engine.jdbc.mutation.ParameterUsage; import org.hibernate.engine.jdbc.mutation.ParameterUsage;
import org.hibernate.engine.jdbc.mutation.TableInclusionChecker; 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.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.generator.BeforeExecutionGenerator; import org.hibernate.generator.BeforeExecutionGenerator;
@ -304,9 +303,7 @@ public class InsertCoordinator extends AbstractMutationCoordinator {
} }
private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) {
return session.getFactory() return mutationExecutorService
.getServiceRegistry()
.getService( MutationExecutorService.class )
.createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session ); .createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session );
} }

View File

@ -989,16 +989,12 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
} }
private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { private MutationExecutor executor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) {
return session.getSessionFactory() return mutationExecutorService
.getFastSessionServices()
.getMutationExecutorService()
.createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session ); .createExecutor( resolveBatchKeyAccess( dynamicUpdate, session ), group, session );
} }
private MutationExecutor updateVersionExecutor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) { private MutationExecutor updateVersionExecutor(SharedSessionContractImplementor session, MutationOperationGroup group, boolean dynamicUpdate) {
return session.getSessionFactory() return mutationExecutorService
.getFastSessionServices()
.getMutationExecutorService()
.createExecutor( resolveUpdateVersionBatchKeyAccess( dynamicUpdate, session ), group, session ); .createExecutor( resolveUpdateVersionBatchKeyAccess( dynamicUpdate, session ), group, session );
} }