mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-27 14:30:16 +00:00
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.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
|
||||
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
|
||||
import static org.hibernate.internal.log.LoggingHelper.toLoggableString;
|
||||
import static org.hibernate.metamodel.mapping.ForeignKeyDescriptor.Nature.TARGET;
|
||||
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
||||
|
||||
/**
|
||||
@ -619,6 +620,14 @@ public void resolveInstance(Object instance) {
|
||||
concreteDescriptor.getIdentifier( entityInstance, session )
|
||||
);
|
||||
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,
|
||||
// otherwise it will be initialized by some other initializer
|
||||
state = entityHolder.getEntityInitializer() == null ? State.INITIALIZED : State.RESOLVED;
|
||||
|
Loading…
x
Reference in New Issue
Block a user