{"record":{"id":"06214b3e51c6c5fc","repo":"hibernate/hibernate-orm","slug":"embeddable-class-s-is-annotated-discriminator","errorCode":null,"errorMessage":"Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy","messagePattern":"Embeddable class '(.+?)' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":685,"sourceCode":"\t\t\t\t\toverrides = parentHolder.getOverriddenColumn( path );\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcolumnPrefix = propertyData.getPropertyName();\n\t\t\t\t\toverrides = holder.getOverriddenColumn( path );\n\t\t\t\t}\n\t\t\t\treturn buildDiscriminatorColumn(\n\t\t\t\t\t\tdiscriminatorColumn,\n\t\t\t\t\t\tdiscriminatorFormula,\n\t\t\t\t\t\toverrides == null ? null : overrides[0],\n\t\t\t\t\t\tcolumnPrefix + \"_\" + DEFAULT_DISCRIMINATOR_COLUMN_NAME,\n\t\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t}\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( String.format(\n\t\t\t\t\t\t\"Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy\",\n\t\t\t\t\t\tclassDetails.getName()\n\t\t\t\t) );\n\t\t\t}\n\t\t\tif ( discriminatorFormula != null ) {\n\t\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\t\t\"Embeddable class '%s' is annotated '@DiscriminatorFormula' but it is not the root of the inheritance hierarchy\",\n\t\t\t\t\t\tclassDetails.getName()\n\t\t\t\t) );\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n\n\tprivate static void bindDiscriminatorColumnToComponent(\n\t\t\tComponent embeddable,\n\t\t\tAnnotatedDiscriminatorColumn discriminatorColumn,\n\t\t\tPropertyHolder holder,","sourceCodeStart":667,"sourceCodeEnd":703,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L667-L703","documentation":"Error \"Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the 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 embeddable class of the 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"}