{"record":{"id":"d58da60d30e9aa64","repo":"hibernate/hibernate-orm","slug":"could-not-retrieve-real-entity-class-no","errorCode":null,"errorMessage":"could not retrieve real entity class [{}#{}] - no Session","messagePattern":"could not retrieve real entity class \\[(.+?)#(.+?)\\] - no Session","errorType":"exception","errorClass":"LazyInitializationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java","lineNumber":120,"sourceCode":"\t\t\treturn replacement;\n\t\t}\n\t\telse {\n\t\t\treturn getTarget();\n\t\t}\n\t}\n\n\t@Override\n\tpublic final Class<?> getPersistentClass() {\n\t\treturn persistentClass;\n\t}\n\n\t@Override\n\tpublic Class<?> getImplementationClass() {\n\t\tif ( !isUninitialized() ) {\n\t\t\treturn getImplementation().getClass();\n\t\t}\n\t\telse if ( getSession() == null ) {\n\t\t\tthrow new LazyInitializationException( \"could not retrieve real entity class [\"\n\t\t\t\t\t\t\t+ getEntityName() + \"#\" + getInternalIdentifier() + \"] - no Session\" );\n\t\t}\n\t\telse {\n\t\t\treturn getEntityDescriptor().hasSubclasses()\n\t\t\t\t\t? getImplementation().getClass()\n\t\t\t\t\t: persistentClass;\n\t\t}\n\t}\n\n}\n","sourceCodeStart":102,"sourceCodeEnd":131,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java#L102-L131","documentation":"Error \"could not retrieve real entity class [{}#{}] - no Session\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A runtime precondition of the Hibernate API is violated.","commonSituations":"Occurs when application code or configuration does not satisfy the documented contract of the API being called.","solutions":["Resolve the entity class while the proxy is still attached to an open Session.","Reload the entity in a new session when needed."],"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"}