hibernate/hibernate-orm · error · MappingException
Attempt to use multiple inheritance strategies : %s & %s
Error message
Attempt to use multiple inheritance strategies : %s & %s
What it means
Error "Attempt to use multiple inheritance strategies : %s & %s" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/jaxb/hbm/transform/HbmXmlTransformer.java:1146
defineInheritance( mappingEntity, InheritanceType.TABLE_PER_CLASS );
}
for ( var hbmQuery : hbmClass.getQuery() ) {
// Tests implied this was the case...
final String name = hbmClass.getName() + "." + hbmQuery.getName();
mappingXmlBinding.getRoot().getNamedQueries().add( transformNamedQuery( hbmQuery, name ) );
}
for ( var hbmQuery : hbmClass.getSqlQuery() ) {
// Tests implied this was the case...
final String name = hbmClass.getName() + "." + hbmQuery.getName();
mappingXmlBinding.getRoot().getNamedNativeQueries().add( transformNamedNativeQuery( hbmQuery, name ) );
}
}
private void defineInheritance(JaxbEntityImpl mappingEntity, InheritanceType strategy) {
if ( mappingEntity.getInheritance() != null && mappingEntity.getInheritance().getStrategy() != strategy ) {
throw new MappingException(
String.format(
Locale.ROOT,
"Attempt to use multiple inheritance strategies : %s & %s",
mappingEntity.getInheritance().getStrategy(),
strategy
),
origin()
);
}
else {
mappingEntity.setInheritance( new JaxbInheritanceImpl() );
mappingEntity.getInheritance().setStrategy( strategy );
}
}
private void transferDiscriminatorSubclass(
JaxbHbmDiscriminatorSubclassEntityType hbmSubclass,
JaxbEntityImpl subclassEntity,View on GitHub (pinned to fad1729dce)
Solutions
- Use exactly one inheritance strategy per entity hierarchy (SINGLE_TABLE, JOINED, or TABLE_PER_CLASS); remove the conflicting strategy annotations/elements.
- Check the hbm.xml being transformed for mixed <joined-subclass> and <subclass>/<union-subclass> usage in one hierarchy.
- Restructure the hierarchy if two strategies were genuinely needed.
When it happens
Trigger: An entity hierarchy mixes different inheritance mapping strategies.
Common situations: Using different <subclass>/<joined-subclass>/<union-subclass> styles, or @Inheritance strategies, within a single hierarchy.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/e7fe6e7ac58a23a7.
Report an issue: GitHub.