hibernate/hibernate-orm · error · LazyInitializationException
Could not initialize proxy [{}#{}]: {}
Error message
Could not initialize proxy [{}#{}]: {} What it means
Error "Could not initialize proxy [{}#{}]: {}" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java:252
target = immediateLoad( session );
initialized = true;
checkTargetState( session );
}
finally {
// make sure the just opened temp session gets closed!
try {
if ( !isJTA ) {
session.getTransaction().commit();
}
session.close();
}
catch (Exception e) {
CORE_LOGGER.unableToCLoseTempSession();
}
}
}
catch (Exception e) {
throw new LazyInitializationException( "Could not initialize proxy ["
+ entityName + "#" + id + "]: " + e.getMessage() );
}
}
else if ( session.isOpenOrWaitingForAutoClose() && session.isConnected() ) {
target = immediateLoad( session );
initialized = true;
checkTargetState( session );
}
else {
throw new LazyInitializationException( "Could not initialize proxy ["
+ entityName + "#" + id + "] - session was closed or disconnected" );
}
}
private Object immediateLoad(SharedSessionContractImplementor session) {
if ( temporalIdentifier != null ) {
final var influencers = session.getLoadQueryInfluencers();
final Object previous = influencers.getTemporalIdentifier();View on GitHub (pinned to fad1729dce)
Solutions
- Inspect the nested cause for the real initialization failure (e.g. missing row, connection error).
- Verify the entity row still exists in the database.
When it happens
Trigger: A lazy proxy is accessed outside the lifecycle of its owning Hibernate Session.
Common situations: LazyInitializationException-style failures when rendering entities after the transaction/Session closed, common in web views and serialization.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/79101d8f288b767b.
Report an issue: GitHub.