{"record":{"id":"281d3476d0b94e74","repo":"hibernate/hibernate-orm","slug":"jpacompliance-is-no-longer-mutable","errorCode":null,"errorMessage":"JpaCompliance is no longer mutable","messagePattern":"JpaCompliance is no longer mutable","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java","lineNumber":1851,"sourceCode":"\t\t\tsqlFunctions = new HashMap<>();\n\t\t}\n\t\tsqlFunctions.put( registrationName, sqlFunction );\n\t}\n\n\tpublic void allowOutOfTransactionUpdateOperations(boolean allow) {\n\t\tthis.allowOutOfTransactionUpdateOperations = allow;\n\t}\n\n\tpublic void enableJpaQueryCompliance(boolean enabled) {\n\t\tmutableJpaCompliance().setQueryCompliance( enabled );\n\t}\n\n\tprivate MutableJpaCompliance mutableJpaCompliance() {\n\t\tif ( jpaCompliance instanceof MutableJpaCompliance mutableJpaCompliance ) {\n\t\t\treturn mutableJpaCompliance;\n\t\t}\n\t\telse {\n\t\t\tthrow new IllegalStateException( \"JpaCompliance is no longer mutable\" );\n\t\t}\n\t}\n\n\tpublic void enableJpaTransactionCompliance(boolean enabled) {\n\t\tmutableJpaCompliance().setTransactionCompliance( enabled );\n\t}\n\n\tpublic void enableJpaClosedCompliance(boolean enabled) {\n\t\tmutableJpaCompliance().setClosedCompliance( enabled );\n\t}\n\n\tpublic void enableJpaProxyCompliance(boolean enabled) {\n\t\tmutableJpaCompliance().setProxyCompliance( enabled );\n\t}\n\n\tpublic void enableJpaCachingCompliance(boolean enabled) {\n\t\tmutableJpaCompliance().setCachingCompliance( enabled );\n\t}","sourceCodeStart":1833,"sourceCodeEnd":1869,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/internal/SessionFactoryOptionsBuilder.java#L1833-L1869","documentation":"Mutability guard in mutableJpaCompliance(): a JPA compliance flag is being changed after the options were built, so the internal MutableJpaCompliance has already been frozen into an immutable JpaCompliance. SessionFactory options may not be mutated after build.","triggerScenarios":"Code attempts to change JPA compliance flags after the settings were frozen.","commonSituations":"Calling SessionFactoryOptionsBuilder compliance setters after the SessionFactory options have been built.","solutions":["Set JPA compliance options before the SessionFactory is built; they are frozen afterwards.","Move jpaCompliance configuration into the bootstrap phase (MetadataBuilder/StandardServiceRegistryBuilder settings).","Remove code that mutates JpaCompliance at runtime."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}