{"record":{"id":"8910b234b6517837","repo":"hibernate/hibernate-orm","slug":"mutability-is-not-allowed-on-entity","errorCode":null,"errorMessage":"@Mutability is not allowed on entity","messagePattern":"@Mutability is not allowed on entity","errorType":"exception","errorClass":"MappingException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":1471,"sourceCode":"\t\tprocessNamedEntityGraphs();\n\t}\n\n\tprivate void checkSubclassEntity() {\n\t\tif ( !isMutable() ) {\n\t\t\tthrow new AnnotationException( \"Entity class '\" + annotatedClass.getName()\n\t\t\t\t\t+ \"' is annotated '@Immutable' but it is a subclass in an entity inheritance hierarchy\"\n\t\t\t\t\t+ \" (only a root class may declare its mutability)\" );\n\t\t}\n\t\tif ( isNotBlank( where ) ) {\n\t\t\tthrow new AnnotationException( \"Entity class '\" + annotatedClass.getName()\n\t\t\t\t\t+ \"' specifies an '@SQLRestriction' but it is a subclass in an entity inheritance hierarchy\"\n\t\t\t\t\t+ \" (only a root class may be specify a restriction)\" );\n\t\t}\n\t}\n\n\tprivate void ensureNoMutabilityPlan() {\n\t\tif ( annotatedClass.hasAnnotationUsage( Mutability.class, modelsContext() ) ) {\n\t\t\tthrow new MappingException( \"@Mutability is not allowed on entity\" );\n\t\t}\n\t}\n\n\tprivate boolean isMutable() {\n\t\treturn !annotatedClass.hasAnnotationUsage( Immutable.class, modelsContext() );\n\t}\n\n\tprivate void registerImportName() {\n\t\ttry {\n\t\t\tfinal var metadataCollector = getMetadataCollector();\n\t\t\tmetadataCollector.addImport( name, persistentClass.getEntityName() );\n\t\t\tfinal String entityName = persistentClass.getEntityName();\n\t\t\tif ( !entityName.equals( name ) ) {\n\t\t\t\tmetadataCollector.addImport( entityName, entityName );\n\t\t\t}\n\t\t}\n\t\tcatch (MappingException me) {\n\t\t\tthrow new AnnotationException( \"Use of the same entity name twice: \" + name, me );","sourceCodeStart":1453,"sourceCodeEnd":1489,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L1453-L1489","documentation":"Error \"@Mutability is not allowed on entity\" thrown in hibernate/hibernate-orm.","triggerScenarios":"@Mutability is placed on an entity, where mutability customizations are not supported.","commonSituations":"@Mutability applied to an @Entity; it is only meaningful for basic-typed attributes and embeddables.","solutions":["Remove @Mutability from the entity; it is not allowed on entity types."],"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"}