Skip to content

Commit cd2ac94

Browse files
stuartwdouglasSanne
authored andcommitted
HHH-10314 Don't create the batch fetch queue to remove entities, as a null queue cannot contain the entity
1 parent 6ecb5ca commit cd2ac94

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

hibernate-core/src/main/java/org/hibernate/engine/internal/StatefulPersistenceContext.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ public Object[] getCachedDatabaseSnapshot(EntityKey key) {
383383
@Override
384384
public void addEntity(EntityKey key, Object entity) {
385385
entitiesByKey.put( key, entity );
386-
getBatchFetchQueue().removeBatchLoadableEntityKey( key );
386+
if( batchFetchQueue != null ) {
387+
getBatchFetchQueue().removeBatchLoadableEntityKey(key);
388+
}
387389
}
388390

389391
@Override
@@ -409,8 +411,10 @@ public Object removeEntity(EntityKey key) {
409411
parentsByChild.clear();
410412
entitySnapshotsByKey.remove( key );
411413
nullifiableEntityKeys.remove( key );
412-
getBatchFetchQueue().removeBatchLoadableEntityKey( key );
413-
getBatchFetchQueue().removeSubselect( key );
414+
if( batchFetchQueue != null ) {
415+
getBatchFetchQueue().removeBatchLoadableEntityKey(key);
416+
getBatchFetchQueue().removeSubselect(key);
417+
}
414418
return entity;
415419
}
416420

0 commit comments

Comments
 (0)