From 6aebd26167f41106e09bfbb1ef1a299065832d5b Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 27 Jun 2019 15:33:05 +0100 Subject: [PATCH] HHH-11147 Avoid allocating a BatchFetchQueue if batching was not enabled --- .../hibernate/event/internal/DefaultLoadEventListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java index 31c396ddf7..126c7d684e 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java @@ -292,8 +292,10 @@ public class DefaultLoadEventListener implements LoadEventListener { } } - // Potentially add a batch-fetch entry into the queue for this entity - persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); + if ( keyToLoad.isBatchLoadable() ) { + // Add a batch-fetch entry into the queue for this entity + persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); + } // This is the crux of HHH-11147 // create the (uninitialized) entity instance - has only id set