Skip to content

Commit 3810727

Browse files
yrodiereSanne
authored andcommitted
HHH-14811 Throw LazyInitializationException on lazy-loading an association on a deleted entity with bytecode enhancement
1 parent 30a5acf commit 3810727

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.hibernate.FetchMode;
3030
import org.hibernate.HibernateException;
3131
import org.hibernate.JDBCException;
32+
import org.hibernate.LazyInitializationException;
3233
import org.hibernate.LockMode;
3334
import org.hibernate.LockOptions;
3435
import org.hibernate.MappingException;
@@ -1149,8 +1150,9 @@ public Object initializeLazyProperty(String fieldName, Object entity, SharedSess
11491150
// for the collection to the just loaded collection
11501151
final EntityEntry ownerEntry = persistenceContext.getEntry( entity );
11511152
if ( ownerEntry == null ) {
1152-
// not good
1153-
throw new AssertionFailure(
1153+
// the entity is not in the session; it was probably deleted,
1154+
// so we cannot load the collection anymore.
1155+
throw new LazyInitializationException(
11541156
"Could not locate EntityEntry for the collection owner in the PersistenceContext"
11551157
);
11561158
}

0 commit comments

Comments
 (0)