HHH-13633 : Bugs join-fetching a collection when scrolling with a stateless session using enhancement as proxy

Make corrections.
This commit is contained in:
Gail Badner 2019-10-14 23:33:39 -07:00
parent 5aa421d697
commit 40a7cee13d
1 changed files with 9 additions and 10 deletions

View File

@ -46,7 +46,6 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.OuterJoinLoadable; import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.query.spi.ScrollableResultsImplementor; import org.hibernate.query.spi.ScrollableResultsImplementor;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
@ -312,11 +311,11 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
final Object proxy = persistenceContext.getProxy( entityKey ); final Object proxy = persistenceContext.getProxy( entityKey );
if ( proxy != null ) { if ( proxy != null ) {
LOG.trace( "Entity proxy found in session cache" ); if ( LOG.isTraceEnabled() ) {
LOG.trace( "Entity proxy found in session cache" );
final LazyInitializer li = ( (HibernateProxy) proxy ).getHibernateLazyInitializer(); }
if ( li.isUnwrap() ) { if ( LOG.isDebugEnabled() && ( (HibernateProxy) proxy ).getHibernateLazyInitializer().isUnwrap() ) {
return li.getImplementation(); LOG.debug( "Ignoring NO_PROXY to honor laziness" );
} }
return persistenceContext.narrowProxy( proxy, persister, entityKey, null ); return persistenceContext.narrowProxy( proxy, persister, entityKey, null );
@ -331,11 +330,11 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
} }
return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this ); return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this );
} }
else { else if ( !entityMetamodel.hasSubclasses() ) {
if ( !entityMetamodel.hasSubclasses() ) { return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this );
return bytecodeEnhancementMetadata.createEnhancedProxy( entityKey, false, this );
}
} }
// If we get here, then the entity class has subclasses and there is no HibernateProxy factory.
// The entity will get loaded below.
} }
else { else {
if ( persister.hasProxy() ) { if ( persister.hasProxy() ) {