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 905e39290f..9c0bb79922 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 @@ -279,7 +279,7 @@ public class DefaultLoadEventListener implements LoadEventListener { } else if ( options.isAllowProxyCreation() ) { // return a new proxy - return proxyOrCached( event, persister, keyToLoad, options ); + return createProxyIfNecessary( event, persister, keyToLoad, options ); } else { // return a newly loaded object @@ -349,27 +349,6 @@ public class DefaultLoadEventListener implements LoadEventListener { return createProxy( event, persister, keyToLoad ); } - private static Object proxyOrCached(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadType options) { - final PersistenceContext persistenceContext = event.getSession().getPersistenceContext(); - final Object existing = persistenceContext.getEntity( keyToLoad ); - if ( existing != null ) { - return options.isCheckDeleted() && wasDeleted( persistenceContext, existing ) ? null : existing; - } - if ( persister.hasSubclasses() ) { - final Object cachedEntity = CacheEntityLoaderHelper.INSTANCE.loadFromSecondLevelCache( - event.getSession(), - null, - LockMode.NONE, - persister, - keyToLoad - ); - if ( cachedEntity != null ) { - return cachedEntity; - } - } - return createProxyIfNecessary( event, persister, keyToLoad, options ); - } - /** * Given a proxy, initialize it and/or narrow it provided either * is necessary.