HHH-18631 AssertionError when loading an entity after removing another, associated entity
This commit is contained in:
parent
dd9f79096f
commit
34b479a719
|
@ -85,7 +85,6 @@ 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.util.NullnessUtil.castNonNull;
|
import static org.hibernate.internal.util.NullnessUtil.castNonNull;
|
||||||
import static org.hibernate.metamodel.mapping.ForeignKeyDescriptor.Nature.TARGET;
|
|
||||||
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -931,12 +930,15 @@ public class EntityInitializerImpl extends AbstractInitializer<EntityInitializer
|
||||||
);
|
);
|
||||||
data.entityHolder = persistenceContext.getEntityHolder( data.entityKey );
|
data.entityHolder = persistenceContext.getEntityHolder( data.entityKey );
|
||||||
if ( data.entityHolder == null ) {
|
if ( data.entityHolder == null ) {
|
||||||
// Entity was most probably removed in the same session without setting the reference to null
|
// Entity was most probably removed in the same session without setting this association to null.
|
||||||
resolveKey( data );
|
// Since this load request can happen through `find()` which doesn't auto-flush on association joins,
|
||||||
assert data.getState() == State.MISSING;
|
// the entity must be fully initialized, even if it is removed already
|
||||||
assert referencedModelPart instanceof ToOneAttributeMapping
|
data.entityHolder = persistenceContext.claimEntityHolderIfPossible(
|
||||||
&& ( (ToOneAttributeMapping) referencedModelPart ).getSideNature() == TARGET;
|
data.entityKey,
|
||||||
return;
|
data.entityInstanceForNotify,
|
||||||
|
rowProcessingState.getJdbcValuesSourceProcessingState(),
|
||||||
|
this
|
||||||
|
);
|
||||||
}
|
}
|
||||||
if ( data.concreteDescriptor.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
|
if ( data.concreteDescriptor.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
|
||||||
&& isPersistentAttributeInterceptable( data.entityInstanceForNotify )
|
&& isPersistentAttributeInterceptable( data.entityInstanceForNotify )
|
||||||
|
|
Loading…
Reference in New Issue