{"record":{"id":"5d773e4ed1b6f5a9","repo":"hibernate/hibernate-orm","slug":"could-not-retrieve-real-entity-name-no-s","errorCode":null,"errorMessage":"Could not retrieve real entity name [{}#{}] - no session","messagePattern":"Could not retrieve real entity name \\[(.+?)#(.+?)\\] - no session","errorType":"exception","errorClass":"LazyInitializationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java","lineNumber":367,"sourceCode":"\t\treturn target;\n\t}\n\n\t@Override\n\tpublic final void setImplementation(Object target) {\n\t\tthis.target = target;\n\t\tinitialized = true;\n\t}\n\n\t@Override\n\tpublic final Object getImplementation(SharedSessionContractImplementor session) throws HibernateException {\n\t\tfinal var entityKey = generateEntityKeyOrNull( getInternalIdentifier(), session, getEntityName() );\n\t\treturn entityKey == null ? null : session.getPersistenceContext().getEntity( entityKey );\n\t}\n\n\t@Override\n\tpublic String getImplementationEntityName() {\n\t\tif ( session == null ) {\n\t\t\tthrow new LazyInitializationException( \"Could not retrieve real entity name [\"\n\t\t\t\t\t+ entityName + \"#\" + id + \"] - no session\" );\n\t\t}\n\t\tif ( getEntityDescriptor().hasSubclasses() ) {\n\t\t\tinitialize();\n\t\t\treturn getFactory().bestGuessEntityName( target );\n\t\t}\n\t\treturn entityName;\n\t}\n\n\t/**\n\t * Getter for property \"target\".\n\t * <p>\n\t * Same as {@link #getImplementation()} except that this method will not force initialization.\n\t *\n\t * @return Value for property \"target\".\n\t */\n\tprotected final Object getTarget() {\n\t\treturn target;","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java#L349-L385","documentation":"Error \"Could not retrieve real entity name [{}#{}] - 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 name while a Session is available.","Avoid calling getEntityName on detached proxies."],"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"}