{"record":{"id":"0a68345f18c537f7","repo":"hibernate/hibernate-orm","slug":"entity-class-classname-is-annotated-discrimi","errorCode":null,"errorMessage":"Entity class '<className>' is annotated '@DiscriminatorColumn' but it is not the root of the entity inheritance hierarchy","messagePattern":"Entity class '<className>' is annotated '@DiscriminatorColumn' but it is not the root of the entity inheritance hierarchy","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java","lineNumber":1040,"sourceCode":"\t\t}\n\t}\n\n\t/**\n\t * Process all discriminator-related metadata per rules for \"single table\" inheritance\n\t */\n\tprivate AnnotatedDiscriminatorColumn processSingleTableDiscriminatorProperties(InheritanceState inheritanceState) {\n\t\tfinal var discriminatorColumn = annotatedClass.getAnnotationUsage( DiscriminatorColumn.class, modelsContext() );\n\t\tfinal var discriminatorFormula = getOverridableAnnotation( annotatedClass, DiscriminatorFormula.class, context );\n\n\t\tif ( !inheritanceState.hasParents()\n\t\t\t\t|| annotatedClass.hasAnnotationUsage( Inheritance.class, modelsContext() ) ) {\n\t\t\treturn buildDiscriminatorColumn( discriminatorColumn, discriminatorFormula,\n\t\t\t\t\tnull, DEFAULT_DISCRIMINATOR_COLUMN_NAME, context );\n\t\t}\n\t\telse {\n\t\t\t// not a root entity\n\t\t\tif ( discriminatorColumn != null ) {\n\t\t\t\tthrow new AnnotationException( \"Entity class '\" + annotatedClass.getName()\n\t\t\t\t\t\t+  \"' is annotated '@DiscriminatorColumn' but it is not the root of the entity inheritance hierarchy\");\n\t\t\t}\n\t\t\tif ( discriminatorFormula != null ) {\n\t\t\t\tthrow new AnnotationException( \"Entity class '\" + annotatedClass.getName()\n\t\t\t\t\t\t+  \"' is annotated '@DiscriminatorFormula' but it is not the root of the entity inheritance hierarchy\");\n\t\t\t}\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/**\n\t * Process all discriminator-related metadata per rules for \"joined\" inheritance, taking\n\t * into account {@value AvailableSettings#IMPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS}\n\t * and {@value AvailableSettings#IGNORE_EXPLICIT_DISCRIMINATOR_COLUMNS_FOR_JOINED_SUBCLASS}.\n\t */\n\tprivate AnnotatedDiscriminatorColumn processJoinedDiscriminatorProperties(InheritanceState inheritanceState) {\n\t\tfinal var modelContext = modelsContext();\n","sourceCodeStart":1022,"sourceCodeEnd":1058,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java#L1022-L1058","documentation":"Error \"Entity class '<className>' is annotated '@DiscriminatorColumn' but it is not the root of the entity inheritance hierarchy\" 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":["Move @DiscriminatorColumn to the root class of the entity inheritance hierarchy."],"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"}