hibernate/hibernate-orm · error · LazyInitializationException
Could not initialize proxy [{}#{}] - the owning session is d
Error message
Could not initialize proxy [{}#{}] - the owning session is disconnected What it means
Error "Could not initialize proxy [{}#{}] - the owning session is disconnected" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java:186
}
@Override
public final void initialize() throws HibernateException {
if ( !initialized ) {
try {
if ( allowLoadOutsideTransaction ) {
permissiveInitialization();
}
else if ( session == null ) {
throw new LazyInitializationException( "Could not initialize proxy ["
+ entityName + "#" + id + "] - no session" );
}
else if ( !session.isOpenOrWaitingForAutoClose() ) {
throw new LazyInitializationException( "Could not initialize proxy ["
+ entityName + "#" + id + "] - the owning session was closed" );
}
else if ( !session.isConnected() ) {
throw new LazyInitializationException( "Could not initialize proxy ["
+ entityName + "#" + id + "] - the owning session is disconnected" );
}
else {
target = immediateLoad( session );
initialized = true;
checkTargetState( session );
}
}
finally {
if ( session != null && !session.isTransactionInProgress() ) {
session.getJdbcCoordinator().afterTransaction();
}
}
}
else {
checkTargetState( session );
}
}View on GitHub (pinned to fad1729dce)
Solutions
- Reconnect the Session before initializing the proxy.
- Load the entity fresh in a connected session.
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/d3c3b4a464be84b2.
Report an issue: GitHub.