HHH-17750 Handle bytecode-enhanced proxies in context identifier
This commit is contained in:
parent
2c3909470b
commit
fb4580cb6e
|
@ -49,6 +49,7 @@ import org.hibernate.TransientObjectException;
|
|||
import org.hibernate.TypeMismatchException;
|
||||
import org.hibernate.UnknownProfileException;
|
||||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.internal.StatefulPersistenceContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
|
@ -60,6 +61,7 @@ import org.hibernate.engine.spi.EntityEntry;
|
|||
import org.hibernate.engine.spi.EntityKey;
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
@ -160,6 +162,8 @@ import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_RETRIEVE_MODE
|
|||
import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_STORE_MODE;
|
||||
import static org.hibernate.cfg.AvailableSettings.STATEMENT_BATCH_SIZE;
|
||||
import static org.hibernate.cfg.AvailableSettings.USE_SUBSELECT_FETCH;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||
import static org.hibernate.event.spi.LoadEventListener.IMMEDIATE_LOAD;
|
||||
import static org.hibernate.event.spi.LoadEventListener.INTERNAL_LOAD_EAGER;
|
||||
import static org.hibernate.event.spi.LoadEventListener.INTERNAL_LOAD_LAZY;
|
||||
|
@ -1529,10 +1533,16 @@ public class SessionImpl
|
|||
if ( lazyInitializer != null ) {
|
||||
return lazyInitializer.getInternalIdentifier();
|
||||
}
|
||||
else {
|
||||
final EntityEntry entry = persistenceContext.getEntry( object );
|
||||
return entry != null ? entry.getId() : null;
|
||||
else if ( isPersistentAttributeInterceptable( object ) ) {
|
||||
final PersistentAttributeInterceptor interceptor =
|
||||
asPersistentAttributeInterceptable( object ).$$_hibernate_getInterceptor();
|
||||
if ( interceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
|
||||
return ( (EnhancementAsProxyLazinessInterceptor) interceptor ).getIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
final EntityEntry entry = persistenceContext.getEntry( object );
|
||||
return entry != null ? entry.getId() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue