hibernate/hibernate-orm · error · MappingException

discriminator mapping [%s] named both <column/> and <formula

Error message

discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed

What it means

Error "discriminator mapping [%s] named both <column/> and <formula/>, but only one or other allowed" thrown in hibernate/hibernate-orm.

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)

Solutions

  1. 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.

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.