{"record":{"id":"5ac34b83831b9fa3","repo":"hibernate/hibernate-orm","slug":"embeddable-class-s-defines-an-inheritance-hiera-5ac34b","errorCode":null,"errorMessage":"Embeddable class '%s' defines an inheritance hierarchy and cannot be used with a custom '@CompositeType'","messagePattern":"Embeddable class '(.+?)' defines an inheritance hierarchy and cannot be used with a custom '@CompositeType'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":733,"sourceCode":"\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,\n\t\t\tMap<String, String> subclassToSuperclass) {\n\t\tfinal List<PropertyData> classElements = new ArrayList<>();\n\t\t//embeddable elements can have type defs\n\t\tfinal var container = new PropertyContainer( returnedClassOrElement, annotatedClass, propertyAccessor );\n\t\taddElementsOfClass( classElements, container, context, 0 );\n\t\t//add elements of the embeddable's mapped superclasses","sourceCodeStart":715,"sourceCodeEnd":751,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L715-L751","documentation":"Error \"Embeddable class '%s' defines an inheritance hierarchy and cannot be used with a custom '@CompositeType'\" 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 custom @CompositeType or use an embeddable without inheritance for the composite type."],"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"}