{"record":{"id":"22d5747935b903a5","repo":"hibernate/hibernate-orm","slug":"entity-entityname-is-a-subclass-in-an-entity-i","errorCode":null,"errorMessage":"Entity '<entityName>' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity","messagePattern":"Entity '<entityName>' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":783,"sourceCode":"\t\t\t// No id property found in the associated class,\n\t\t\t// or multiple id properties but no @IdClass\n\t\t\treturn false;\n\t\t}\n\t}\n\n\tprivate Component bindIdClass(\n\t\t\tPropertyData inferredData,\n\t\t\tPropertyData baseInferredData,\n\t\t\tPropertyHolder propertyHolder,\n\t\t\tAccessType propertyAccessor,\n\t\t\tMetadataBuildingContext buildingContext,\n\t\t\tMap<ClassDetails, InheritanceState> inheritanceStates) {\n\t\tpropertyHolder.setInIdClass( true );\n\n\t\t// Fill simple value and property since and Id is a property\n\t\tfinal var persistentClass = propertyHolder.getPersistentClass();\n\t\tif ( !( persistentClass instanceof RootClass rootClass ) ) {\n\t\t\tthrow new AnnotationException( \"Entity '\" + persistentClass.getEntityName()\n\t\t\t\t\t+ \"' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity\" );\n\t\t}\n\t\tfinal var id = fillEmbeddable(\n\t\t\t\tpropertyHolder,\n\t\t\t\tinferredData,\n\t\t\t\tbaseInferredData,\n\t\t\t\tpropertyAccessor,\n\t\t\t\tannotatedClass,\n\t\t\t\tfalse,\n\t\t\t\tthis,\n\t\t\t\ttrue,\n\t\t\t\tfalse,\n\t\t\t\tfalse,\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\tnull,\n\t\t\t\tbuildingContext,\n\t\t\t\tinheritanceStates,","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L765-L801","documentation":"Error \"Entity '<entityName>' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity\" thrown in hibernate/hibernate-orm.","triggerScenarios":"An annotation restricted to the root of an inheritance hierarchy is placed on a subclass (or the hierarchy rules are otherwise violated).","commonSituations":"SINGLE_TABLE/JOINED hierarchies where @Table, @DiscriminatorColumn, @DiscriminatorFormula, @Cache, @Immutable, @Id or @Version are declared on the wrong class of the hierarchy.","solutions":["Remove the identifier redefinition from the subclass; only the root entity declares the identifier."],"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"}