hibernate/hibernate-orm · error · LazyInitializationException
Could not locate EntityEntry for the collection owner in…
Error message
Could not locate EntityEntry for the collection owner in the PersistenceContext
What it means
Internal invariant failure during lazy collection initialization: the session's persistence context holds the collection but has no EntityEntry for the collection's owner entity, so Hibernate cannot determine the owner's state needed to finish initialization. This indicates corrupted or unusual persistence-context state (owner evicted while its collection remains), not a user input error.
Solutions
- Load the collection through its managed owner within the same session; avoid operating on collections whose owner was evicted or loaded elsewhere.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown during collection processing when the persistence context has no EntityEntry for the collection's owner entity.
Common situations: See trigger scenarios.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/3fc74ac8dc1352be.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java:1652
// see if there is already a collection instance associated with the session
// NOTE: can this ever happen?
final var collection = getCollection( entity, collectionType, session, persister );
final var interceptor = asPersistentAttributeInterceptable( entity ).$$_hibernate_getInterceptor();
assert interceptor != null : "Expecting bytecode interceptor to be non-null";
interceptor.attributeInitialized( fieldName );
final var persistenceContext = session.getPersistenceContextInternal();
if ( collectionType.isArrayType() ) {
persistenceContext.addCollectionHolder( collection );
}
// update the "state" of the owning entity's EntityEntry to overwrite the
// UNFETCHED_PROPERTY for the collection to the just-loaded collection
final var ownerEntry = persistenceContext.getEntry( entity );
if ( ownerEntry == null ) {
// the entity is not in the session; it was probably deleted,
// so we cannot load the collection anymore.
throw new LazyInitializationException(
"Could not locate EntityEntry for the collection owner in the PersistenceContext"
);
}
ownerEntry.overwriteLoadedStateCollectionValue( fieldName, collection );
return collection;
}
private static PersistentCollection<?> getCollection(
Object entity,
CollectionType collectionType,
SharedSessionContractImplementor session,
CollectionPersister persister) {
final var persistenceContext = session.getPersistenceContextInternal();
final var entry = persistenceContext.getEntry( entity );
final Object key = getCollectionKey( persister, entity, entry, session );
assert key != null;
final var collection = persistenceContext.getCollection( session.generateCollectionKey( persister, key ) );View on GitHub (pinned to fad1729dce)