From 7abdde7a6263e231c81c66723c6647bc4587120f Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Tue, 8 Jan 2013 00:20:34 -0500 Subject: [PATCH] HHH-7911 NPE in TwoPhaseLoad#initializeEntity --- .../java/org/hibernate/engine/internal/TwoPhaseLoad.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java index 00e953517a..e5ac56a056 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/TwoPhaseLoad.java @@ -126,6 +126,9 @@ public final class TwoPhaseLoad { final PostLoadEvent postLoadEvent) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); final EntityEntry entityEntry = persistenceContext.getEntry(entity); + if ( entityEntry == null ) { + throw new AssertionFailure( "possible non-threadsafe access to the session" ); + } final EntityPersister persister = entityEntry.getPersister(); final Serializable id = entityEntry.getId(); @@ -145,10 +148,6 @@ public final class TwoPhaseLoad { final SessionImplementor session, final PreLoadEvent preLoadEvent, final PostLoadEvent postLoadEvent) throws HibernateException { - if ( entityEntry == null ) { - throw new AssertionFailure( "possible non-threadsafe access to the session" ); - } - final PersistenceContext persistenceContext = session.getPersistenceContext(); EntityPersister persister = entityEntry.getPersister(); Serializable id = entityEntry.getId();