{"record":{"id":"79101d8f288b767b","repo":"hibernate/hibernate-orm","slug":"could-not-initialize-proxy","errorCode":null,"errorMessage":"Could not initialize proxy [{}#{}]: {}","messagePattern":"Could not initialize proxy \\[(.+?)#(.+?)\\]: (.+?)","errorType":"exception","errorClass":"LazyInitializationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java","lineNumber":252,"sourceCode":"\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\tfinally {\n\t\t\t\t\t// make sure the just opened temp session gets closed!\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif ( !isJTA ) {\n\t\t\t\t\t\t\tsession.getTransaction().commit();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsession.close();\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\tCORE_LOGGER.unableToCLoseTempSession();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new LazyInitializationException( \"Could not initialize proxy [\"\n\t\t\t\t\t\t+ entityName + \"#\" + id + \"]: \" + e.getMessage() );\n\t\t\t}\n\t\t}\n\t\telse if ( session.isOpenOrWaitingForAutoClose() && session.isConnected() ) {\n\t\t\ttarget = immediateLoad( session );\n\t\t\tinitialized = true;\n\t\t\tcheckTargetState( session );\n\t\t}\n\t\telse {\n\t\t\tthrow new LazyInitializationException( \"Could not initialize proxy [\"\n\t\t\t\t\t+ entityName + \"#\" + id + \"] - session was closed or disconnected\" );\n\t\t}\n\t}\n\n\tprivate Object immediateLoad(SharedSessionContractImplementor session) {\n\t\tif ( temporalIdentifier != null ) {\n\t\t\tfinal var influencers = session.getLoadQueryInfluencers();\n\t\t\tfinal Object previous = influencers.getTemporalIdentifier();","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java#L234-L270","documentation":"Error \"Could not initialize proxy [{}#{}]: {}\" 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":["Inspect the nested cause for the real initialization failure (e.g. missing row, connection error).","Verify the entity row still exists in the database."],"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"}