HHH-18212 Handle entity in existing state removed from current session
This commit is contained in:
parent
46e0f43567
commit
c5cbe20bd1
|
@ -81,6 +81,7 @@ import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCH
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||||
import static org.hibernate.internal.log.LoggingHelper.toLoggableString;
|
import static org.hibernate.internal.log.LoggingHelper.toLoggableString;
|
||||||
|
import static org.hibernate.metamodel.mapping.ForeignKeyDescriptor.Nature.TARGET;
|
||||||
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -619,6 +620,14 @@ public class EntityInitializerImpl extends AbstractInitializer implements Entity
|
||||||
concreteDescriptor.getIdentifier( entityInstance, session )
|
concreteDescriptor.getIdentifier( entityInstance, session )
|
||||||
);
|
);
|
||||||
entityHolder = session.getPersistenceContextInternal().getEntityHolder( entityKey );
|
entityHolder = session.getPersistenceContextInternal().getEntityHolder( entityKey );
|
||||||
|
if ( entityHolder == null ) {
|
||||||
|
// Entity was most probably removed in the same session
|
||||||
|
resolveKey();
|
||||||
|
assert state == State.MISSING;
|
||||||
|
assert referencedModelPart instanceof ToOneAttributeMapping
|
||||||
|
&& ( (ToOneAttributeMapping) referencedModelPart ).getSideNature() == TARGET;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If the entity initializer is null, we know the entity is fully initialized,
|
// If the entity initializer is null, we know the entity is fully initialized,
|
||||||
// otherwise it will be initialized by some other initializer
|
// otherwise it will be initialized by some other initializer
|
||||||
state = entityHolder.getEntityInitializer() == null ? State.INITIALIZED : State.RESOLVED;
|
state = entityHolder.getEntityInitializer() == null ? State.INITIALIZED : State.RESOLVED;
|
||||||
|
|
Loading…
Reference in New Issue