hibernate/hibernate-orm · error · MappingException
discriminator mapping
Error message
discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed
What it means
The <discriminator> mapping of an entity declares both a <column/> element and a <formula/> element (or both attributes). A discriminator may be backed by exactly one of a column or a formula; remove the unused declaration.
Solutions
- Keep either the <column/> or the <formula/> mapping on the discriminator, not both.
Example fix
Keep either the <column/> or the <formula/> mapping on the discriminator, not both.
Defensive patterns
Strategy: validation
When it happens
Trigger: An hbm.xml / orm.xml mapping document violates a mapping rule during bootstrap.
Common situations: Legacy XML mappings with invalid combinations (column+formula, mixed inheritance, missing identifiers, bad extends references).
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/62f28f3b9f53af25.
Report an issue: GitHub.
Appendix: source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/EntityHierarchySourceImpl.java:200
}
@Override
public String getFormulaAttribute() {
return jaxbDiscriminatorMapping.getFormulaAttribute();
}
@Override
public String getColumnAttribute() {
return jaxbDiscriminatorMapping.getColumnAttribute();
}
private List columnOrFormulas;
@Override
public List getColumnOrFormulaElements() {
if ( columnOrFormulas == null ) {
if ( jaxbDiscriminatorMapping.getColumn() != null ) {
if ( jaxbDiscriminatorMapping.getFormula() != null ) {
throw new MappingException(
String.format(
Locale.ENGLISH,
"discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed",
rootEntitySource.getEntityNamingSource().getEntityName()
),
rootEntitySource.sourceMappingDocument().getOrigin()
);
}
else {
columnOrFormulas = Collections.singletonList( jaxbDiscriminatorMapping.getColumn() );
}
}
else {
if ( jaxbDiscriminatorMapping.getFormula() != null ) {
columnOrFormulas = Collections.singletonList( jaxbDiscriminatorMapping.getFormula() );
}
else {
columnOrFormulas = Collections.emptyList();View on GitHub (pinned to fad1729dce)