{"record":{"id":"62d7f57202d3ba8b","repo":"hibernate/hibernate-orm","slug":"cannot-call-isreadonlybeforeattachedtosession-when","errorCode":null,"errorMessage":"Cannot call isReadOnlyBeforeAttachedToSession when isReadOnlySettingAvailable == true [{}#{}]","messagePattern":"Cannot call isReadOnlyBeforeAttachedToSession when isReadOnlySettingAvailable == true \\[(.+?)#(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java","lineNumber":450,"sourceCode":"\t\t}\n\t}\n\n\t/**\n\t * Get the read-only/modifiable setting that should be put in effect when it is\n\t * attached to a session.\n\t * <p>\n\t * This method should only be called during serialization when read-only/modifiable\n\t * setting is not available, that is, if {@code isReadOnlySettingAvailable() == false}\n\t *\n\t * @return {@code null}, if the default setting should be used;\n\t *         {@code true}, for read-only;\n\t *         {@code false}, for modifiable\n\t *\n\t * @throws IllegalStateException if {@code isReadOnlySettingAvailable() == true}\n\t */\n\tpublic final Boolean isReadOnlyBeforeAttachedToSession() {\n\t\tif ( isReadOnlySettingAvailable() ) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"Cannot call isReadOnlyBeforeAttachedToSession when isReadOnlySettingAvailable == true [\"\n\t\t\t\t\t\t\t+ entityName + \"#\" + id + \"]\"\n\t\t\t);\n\t\t}\n\t\treturn readOnlyBeforeAttachedToSession;\n\t}\n\n\t/**\n\t * Get whether the proxy can load data even if it's not attached to a session\n\t * with an ongoing transaction.\n\t * <p>\n\t * This method should only be called during serialization, and only makes sense\n\t * after a call to {@link #prepareForPossibleLoadingOutsideTransaction()}.\n\t *\n\t * @return {@code true} if out-of-transaction loads are allowed,\n\t *         {@code false} otherwise.\n\t */\n\tprotected boolean isAllowLoadOutsideTransaction() {","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java#L432-L468","documentation":"Error \"Cannot call isReadOnlyBeforeAttachedToSession 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":["Only call isReadOnlyBeforeAttachedToSession when the read-only setting is unavailable.","Check isReadOnlySettingAvailable() first."],"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"}