HHH-17594 HHH-17665 Fix proxy narrowing for delayed subtype entities
This commit is contained in:
parent
8ed1e1cb40
commit
8be3a1db85
|
@ -898,9 +898,14 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
|
||||
@Override
|
||||
public Object proxyFor(EntityHolder holder) throws HibernateException {
|
||||
return proxyFor( holder, holder.getDescriptor() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object proxyFor(EntityHolder holder, EntityPersister persister) {
|
||||
final Object proxy = holder.getProxy();
|
||||
return proxy != null && holder.getDescriptor().hasProxy()
|
||||
? narrowProxy( proxy, holder.getDescriptor(), holder.getEntityKey(), holder.getEntity() )
|
||||
return proxy != null && persister.hasProxy()
|
||||
? narrowProxy( proxy, persister, holder.getEntityKey(), holder.getEntity() )
|
||||
: holder.getEntity();
|
||||
}
|
||||
|
||||
|
|
|
@ -348,10 +348,20 @@ public interface PersistenceContext {
|
|||
Object proxyFor(Object impl);
|
||||
|
||||
/**
|
||||
* Return the existing proxy associated with the given {@code EntityKey}, or the
|
||||
* argument (the entity associated with the key) if no proxy exists.
|
||||
* (slower than the form above)
|
||||
* Return the existing {@linkplain EntityHolder#getProxy() proxy} associated with
|
||||
* the given {@link EntityHolder}, or the {@linkplain EntityHolder#getEntity() entity}
|
||||
* if no proxy exists.
|
||||
*/
|
||||
Object proxyFor(EntityHolder holder, EntityPersister persister);
|
||||
|
||||
/**
|
||||
* Return the existing {@linkplain EntityHolder#getProxy() proxy} associated with
|
||||
* the given {@link EntityHolder}, or the {@linkplain EntityHolder#getEntity() entity}
|
||||
* if it contains no proxy.
|
||||
*
|
||||
* @deprecated Use {@link #proxyFor(EntityHolder, EntityPersister)} instead.
|
||||
*/
|
||||
@Deprecated( forRemoval = true )
|
||||
Object proxyFor(EntityHolder holder);
|
||||
|
||||
/**
|
||||
|
|
|
@ -157,7 +157,7 @@ public class EntityDelayedFetchInitializer implements EntityInitializer {
|
|||
final EntityKey entityKey = new EntityKey( identifier, concreteDescriptor );
|
||||
final EntityHolder holder = persistenceContext.getEntityHolder( entityKey );
|
||||
if ( holder != null && holder.getEntity() != null ) {
|
||||
entityInstance = persistenceContext.proxyFor( holder );
|
||||
entityInstance = persistenceContext.proxyFor( holder, concreteDescriptor );
|
||||
}
|
||||
// For primary key based mappings we only use bytecode-laziness if the attribute is optional,
|
||||
// because the non-optionality implies that it is safe to have a proxy
|
||||
|
|
Loading…
Reference in New Issue