From 57befd1a0802b1c154dab67e5293d95b31161c71 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Mon, 14 Oct 2019 23:29:47 -0700 Subject: [PATCH] HHH-13640 : Correct DefaultLoadEventListener#proxyOrLoad to work properly enhancement but no HibernateProxy factory --- .../internal/DefaultLoadEventListener.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 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 937235e559..4c9474f985 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 @@ -319,15 +319,18 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i return createProxy( event, persister, keyToLoad, persistenceContext ); } } + if ( !entityMetamodel.hasSubclasses() ) { + if ( keyToLoad.isBatchLoadable() ) { + // 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 + return persister.getBytecodeEnhancementMetadata().createEnhancedProxy( keyToLoad, true, session ); } - - // This is the crux of HHH-11147 - // create the (uninitialized) entity instance - has only id set - return persister.getBytecodeEnhancementMetadata().createEnhancedProxy( keyToLoad, true, session ); + // If we get here, then the entity class has subclasses and there is no HibernateProxy factory. + // The entity will get loaded below. } else { if ( persister.hasProxy() ) {