diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 88015b421a..3297cdc8c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -560,7 +560,7 @@ public class SessionImpl throw new TransientObjectException( "Given object not associated with the session" ); } - if ( e.getStatus() != Status.MANAGED ) { + if ( e.getStatus().isDeletedOrGone() ) { throw new ObjectDeletedException( "The given object was deleted", e.getId(), diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java index f2c0763412..d6e2fc51b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderHelper.java @@ -19,7 +19,6 @@ import org.hibernate.engine.spi.EntityEntry; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.engine.spi.Status; import org.hibernate.engine.spi.SubselectFetch; import org.hibernate.event.spi.EventSource; import org.hibernate.loader.LoaderLogging; @@ -55,7 +54,7 @@ public class LoaderHelper { // The user requested a "greater" (i.e. more restrictive) form of // pessimistic lock - if ( entry.getStatus() != Status.MANAGED ) { + if ( entry.getStatus().isDeletedOrGone()) { throw new ObjectDeletedException( "attempted to lock a deleted instance", entry.getId(),