{"record":{"id":"a7ab143eb275c77f","repo":"hibernate/hibernate-orm","slug":"cannot-call-afterdeserialization-when-isreadonlyse","errorCode":null,"errorMessage":"Cannot call afterDeserialization when isReadOnlySettingAvailable == true [{}#{}]","messagePattern":"Cannot call afterDeserialization when isReadOnlySettingAvailable == true \\[(.+?)#(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java","lineNumber":517,"sourceCode":"\t * <p>\n\t * This method should only be called during deserialization, before associating\n\t * the proxy with a session.\n\t *\n\t * @param readOnlyBeforeAttachedToSession the read-only/modifiable setting to\n\t *        use when associated with a session; null indicates that the default\n\t *        should be used.\n\t * @param sessionFactoryUuid the session factory uuid, to be used if\n\t *        {@code allowLoadOutsideTransaction} is {@code true}.\n\t * @param allowLoadOutsideTransaction whether the proxy can load data even\n\t * if it's not attached to a session with an ongoing transaction.\n\t *\n\t * @throws IllegalStateException if {@code isReadOnlySettingAvailable() == true}\n\t */\n\t/* package-private */\n\tfinal void afterDeserialization(Boolean readOnlyBeforeAttachedToSession,\n\t\t\tString sessionFactoryUuid, String sessionFactoryName, boolean allowLoadOutsideTransaction) {\n\t\tif ( isReadOnlySettingAvailable() ) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"Cannot call afterDeserialization when isReadOnlySettingAvailable == true [\"\n\t\t\t\t\t\t\t+ entityName + \"#\" + id + \"]\"\n\t\t\t);\n\t\t}\n\t\tthis.readOnlyBeforeAttachedToSession = readOnlyBeforeAttachedToSession;\n\t\tthis.sessionFactoryUuid = sessionFactoryUuid;\n\t\tthis.sessionFactoryName = sessionFactoryName;\n\t\tthis.allowLoadOutsideTransaction = allowLoadOutsideTransaction;\n\t}\n\n\t@Override\n\tpublic boolean isUnwrap() {\n\t\treturn unwrap;\n\t}\n\n\t@Override\n\tpublic void setUnwrap(boolean unwrap) {\n\t\tthis.unwrap = unwrap;","sourceCodeStart":499,"sourceCodeEnd":535,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java#L499-L535","documentation":"Error \"Cannot call afterDeserialization when isReadOnlySettingAvailable == true [{}#{}]\" 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":["Call afterDeserialization only on proxies whose read-only setting is not already available.","Follow the documented proxy deserialization lifecycle."],"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"}