Skip to content

Commit

Permalink
HHH-18631 AssertionError when loading an entity after removing anothe…
Browse files Browse the repository at this point in the history
…r, associated entity
  • Loading branch information
dreab8 committed Sep 18, 2024
1 parent eda6acc commit fbfb104
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.persister.entity.EntityPersister;
Expand Down Expand Up @@ -85,7 +86,6 @@
import static org.hibernate.engine.internal.ManagedTypeHelper.asPersistentAttributeInterceptable;
import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttributeInterceptable;
import static org.hibernate.internal.util.NullnessUtil.castNonNull;
import static org.hibernate.metamodel.mapping.ForeignKeyDescriptor.Nature.TARGET;
import static org.hibernate.proxy.HibernateProxy.extractLazyInitializer;

/**
Expand Down Expand Up @@ -933,9 +933,8 @@ public void resolveInstance(Object instance, EntityInitializerData data) {
if ( data.entityHolder == null ) {
// Entity was most probably removed in the same session without setting the reference to null
resolveKey( data );
assert data.getState() == State.MISSING;
assert referencedModelPart instanceof ToOneAttributeMapping
&& ( (ToOneAttributeMapping) referencedModelPart ).getSideNature() == TARGET;
assert referencedModelPart instanceof ToOneAttributeMapping toOneAttributeMapping
&& toOneAttributeMapping.getSideNature() == ForeignKeyDescriptor.Nature.KEY;
return;
}
if ( data.concreteDescriptor.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
Expand Down

0 comments on commit fbfb104

Please sign in to comment.