{"record":{"id":"3adcebfcccaa089e","repo":"hibernate/hibernate-orm","slug":"embeddable-class-s-defines-an-inheritance-hiera-3adceb","errorCode":null,"errorMessage":"Embeddable class '%s' defines an inheritance hierarchy and cannot be used in an '@IdClass'","messagePattern":"Embeddable class '(.+?)' defines an inheritance hierarchy and cannot be used in an '@IdClass'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":727,"sourceCode":"\t\tdiscriminatorColumn.setParent( columns );\n\t\tfinal var discriminatorColumnBinding = new BasicValue( context, embeddable.getTable() );\n\t\tdiscriminatorColumnBinding.setAggregateColumn( embeddable.getAggregateColumn() );\n\t\tembeddable.setDiscriminator( discriminatorColumnBinding );\n\t\tdiscriminatorColumn.linkWithValue( discriminatorColumnBinding );\n\t\tdiscriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );\n\t}\n\n\tprivate static void validateInheritanceIsSupported(\n\t\t\tPropertyHolder holder,\n\t\t\tCompositeUserType<?> compositeUserType) {\n\t\tif ( holder.isOrWithinEmbeddedId() ) {\n\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\t\"Embeddable class '%s' defines an inheritance hierarchy and cannot be used in an '@EmbeddedId'\",\n\t\t\t\t\tholder.getClassName()\n\t\t\t) );\n\t\t}\n\t\telse if ( holder.isInIdClass() ) {\n\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\t\"Embeddable class '%s' defines an inheritance hierarchy and cannot be used in an '@IdClass'\",\n\t\t\t\t\tholder.getClassName()\n\t\t\t) );\n\t\t}\n\t\telse if ( compositeUserType != null ) {\n\t\t\tthrow new AnnotationException( String.format(\n\t\t\t\t\t\"Embeddable class '%s' defines an inheritance hierarchy and cannot be used with a custom '@CompositeType'\",\n\t\t\t\t\tholder.getClassName()\n\t\t\t) );\n\t\t}\n\t}\n\n\tprivate static List<PropertyData> collectClassElements(\n\t\t\tAccessType propertyAccessor,\n\t\t\tMetadataBuildingContext context,\n\t\t\tClassDetails returnedClassOrElement,\n\t\t\tTypeDetails annotatedClass,\n\t\t\tboolean isIdClass,","sourceCodeStart":709,"sourceCodeEnd":745,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L709-L745","documentation":"Error \"Embeddable class '%s' defines an inheritance hierarchy and cannot be used in an '@IdClass'\" 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":["Use an embeddable class without an inheritance hierarchy as the @IdClass."],"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"}