HHH-14471 Fix concurrency issue due to builder sharing in DynamicBatchingEntityLoader

This commit is contained in:
Christian Beikov 2021-03-01 09:53:43 +01:00
parent 1714c022e2
commit 59735d2329
1 changed files with 8 additions and 6 deletions

View File

@ -27,7 +27,7 @@ public class DynamicBatchingEntityLoader extends BatchingEntityLoader {
private static final Logger log = Logger.getLogger( DynamicBatchingEntityLoader.class ); private static final Logger log = Logger.getLogger( DynamicBatchingEntityLoader.class );
private final int maxBatchSize; private final int maxBatchSize;
private final EntityLoader.Builder entityLoaderBuilder; private final LoadQueryInfluencers loadQueryInfluencers;
public DynamicBatchingEntityLoader( public DynamicBatchingEntityLoader(
OuterJoinLoadable persister, OuterJoinLoadable persister,
@ -37,10 +37,7 @@ public class DynamicBatchingEntityLoader extends BatchingEntityLoader {
LoadQueryInfluencers loadQueryInfluencers) { LoadQueryInfluencers loadQueryInfluencers) {
super( persister ); super( persister );
this.maxBatchSize = maxBatchSize; this.maxBatchSize = maxBatchSize;
this.loadQueryInfluencers = loadQueryInfluencers;
entityLoaderBuilder = EntityLoader.forEntity( persister )
.withInfluencers( loadQueryInfluencers )
.withLockOptions( lockOptions );
} }
@Override @Override
@ -67,7 +64,12 @@ public class DynamicBatchingEntityLoader extends BatchingEntityLoader {
log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister(), idsToLoad, session.getFactory() ) ); log.debugf( "Batch loading entity: %s", MessageHelper.infoString( persister(), idsToLoad, session.getFactory() ) );
} }
final EntityLoader dynamicLoader = entityLoaderBuilder.withBatchSize( idsToLoad.length ).byPrimaryKey();
final EntityLoader dynamicLoader = EntityLoader.forEntity( (OuterJoinLoadable) persister() )
.withInfluencers( loadQueryInfluencers )
.withLockOptions( lockOptions )
.withBatchSize( idsToLoad.length )
.byPrimaryKey();
final List<?> results = dynamicLoader.loadEntityBatch( final List<?> results = dynamicLoader.loadEntityBatch(
session, session,