hibernate/hibernate-orm · error · AnnotationException
Entity '<entityName>' is a subclass in an entity inheritance
Error message
Entity '<entityName>' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity
What it means
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.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java:783
// No id property found in the associated class,
// or multiple id properties but no @IdClass
return false;
}
}
private Component bindIdClass(
PropertyData inferredData,
PropertyData baseInferredData,
PropertyHolder propertyHolder,
AccessType propertyAccessor,
MetadataBuildingContext buildingContext,
Map<ClassDetails, InheritanceState> inheritanceStates) {
propertyHolder.setInIdClass( true );
// Fill simple value and property since and Id is a property
final var persistentClass = propertyHolder.getPersistentClass();
if ( !( persistentClass instanceof RootClass rootClass ) ) {
throw new AnnotationException( "Entity '" + persistentClass.getEntityName()
+ "' is a subclass in an entity inheritance hierarchy and may not redefine the identifier of the root entity" );
}
final var id = fillEmbeddable(
propertyHolder,
inferredData,
baseInferredData,
propertyAccessor,
annotatedClass,
false,
this,
true,
false,
false,
null,
null,
null,
buildingContext,
inheritanceStates,View on GitHub (pinned to fad1729dce)
Solutions
- Remove the identifier redefinition from the subclass; only the root entity declares the identifier.
When it happens
Trigger: An annotation restricted to the root of an inheritance hierarchy is placed on a subclass (or the hierarchy rules are otherwise violated).
Common situations: SINGLE_TABLE/JOINED hierarchies where @Table, @DiscriminatorColumn, @DiscriminatorFormula, @Cache, @Immutable, @Id or @Version are declared on the wrong class of the hierarchy.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/22d5747935b903a5.
Report an issue: GitHub.