hibernate/hibernate-orm · error · AnnotationException

Embeddable class '%s' is annotated '@DiscriminatorColumn' bu

Error message

Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy

What it means

Error "Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java:685

					overrides = parentHolder.getOverriddenColumn( path );
				}
				else {
					columnPrefix = propertyData.getPropertyName();
					overrides = holder.getOverriddenColumn( path );
				}
				return buildDiscriminatorColumn(
						discriminatorColumn,
						discriminatorFormula,
						overrides == null ? null : overrides[0],
						columnPrefix + "_" + DEFAULT_DISCRIMINATOR_COLUMN_NAME,
						context
				);
			}
		}
		else {
			// not a root entity
			if ( discriminatorColumn != null ) {
				throw new AnnotationException( String.format(
						"Embeddable class '%s' is annotated '@DiscriminatorColumn' but it is not the root of the inheritance hierarchy",
						classDetails.getName()
				) );
			}
			if ( discriminatorFormula != null ) {
				throw new AnnotationException( String.format(
						"Embeddable class '%s' is annotated '@DiscriminatorFormula' but it is not the root of the inheritance hierarchy",
						classDetails.getName()
				) );
			}
		}
		return null;
	}

	private static void bindDiscriminatorColumnToComponent(
			Component embeddable,
			AnnotatedDiscriminatorColumn discriminatorColumn,
			PropertyHolder holder,

View on GitHub (pinned to fad1729dce)

Solutions

  1. Move @DiscriminatorColumn to the root embeddable class of the inheritance hierarchy.

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/06214b3e51c6c5fc. Report an issue: GitHub.