{"record":{"id":"d3c3b4a464be84b2","repo":"hibernate/hibernate-orm","slug":"could-not-initialize-proxy-the-owning-se-d3c3b4","errorCode":null,"errorMessage":"Could not initialize proxy [{}#{}] - the owning session is disconnected","messagePattern":"Could not initialize proxy \\[(.+?)#(.+?)\\] - the owning session is disconnected","errorType":"exception","errorClass":"LazyInitializationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java","lineNumber":186,"sourceCode":"\t}\n\n\t@Override\n\tpublic final void initialize() throws HibernateException {\n\t\tif ( !initialized ) {\n\t\t\ttry {\n\t\t\t\tif ( allowLoadOutsideTransaction ) {\n\t\t\t\t\tpermissiveInitialization();\n\t\t\t\t}\n\t\t\t\telse if ( session == null ) {\n\t\t\t\t\tthrow new LazyInitializationException( \"Could not initialize proxy [\"\n\t\t\t\t\t\t\t+ entityName + \"#\" + id + \"] - no session\" );\n\t\t\t\t}\n\t\t\t\telse if ( !session.isOpenOrWaitingForAutoClose() ) {\n\t\t\t\t\tthrow new LazyInitializationException( \"Could not initialize proxy [\"\n\t\t\t\t\t\t\t+ entityName + \"#\" + id + \"] - the owning session was closed\" );\n\t\t\t\t}\n\t\t\t\telse if ( !session.isConnected() ) {\n\t\t\t\t\tthrow new LazyInitializationException( \"Could not initialize proxy [\"\n\t\t\t\t\t\t\t+ entityName + \"#\" + id + \"] - the owning session is disconnected\" );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\ttarget = immediateLoad( session );\n\t\t\t\t\tinitialized = true;\n\t\t\t\t\tcheckTargetState( session );\n\t\t\t\t}\n\t\t\t}\n\t\t\tfinally {\n\t\t\t\tif ( session != null && !session.isTransactionInProgress() ) {\n\t\t\t\t\tsession.getJdbcCoordinator().afterTransaction();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse {\n\t\t\tcheckTargetState( session );\n\t\t}\n\t}","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java#L168-L204","documentation":"Error \"Could not initialize proxy [{}#{}] - the owning session is disconnected\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A lazy proxy is accessed outside the lifecycle of its owning Hibernate Session.","commonSituations":"LazyInitializationException-style failures when rendering entities after the transaction/Session closed, common in web views and serialization.","solutions":["Reconnect the Session before initializing the proxy.","Load the entity fresh in a connected session."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}