HHH-18024 fix getLockMode() on read-only entity

it resulted in spurious exception claiming entity was deleted

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-04-28 14:10:10 +02:00
parent 789cc12b8e
commit 1657702015
2 changed files with 2 additions and 3 deletions

View File

@ -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(),

View File

@ -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(),