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 30dc9add99
commit c1a7a14d1c
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 final int maxBatchSize;
private final EntityLoader.Builder entityLoaderBuilder;
private final LoadQueryInfluencers loadQueryInfluencers;
public DynamicBatchingEntityLoader(
OuterJoinLoadable persister,
@ -37,10 +37,7 @@ public class DynamicBatchingEntityLoader extends BatchingEntityLoader {
LoadQueryInfluencers loadQueryInfluencers) {
super( persister );
this.maxBatchSize = maxBatchSize;
entityLoaderBuilder = EntityLoader.forEntity( persister )
.withInfluencers( loadQueryInfluencers )
.withLockOptions( lockOptions );
this.loadQueryInfluencers = loadQueryInfluencers;
}
@Override
@ -67,7 +64,12 @@ public class DynamicBatchingEntityLoader extends BatchingEntityLoader {
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(
session,