hibernate/hibernate-orm · error · AnnotationException

Property ' ' is inherited from entity ' ' and may not be…

Error message

Property '<name>' is inherited from entity '<entityName>' and may not be overridden using '@<overrideAnnotation>' in entity subclass '<className>'

What it means

checkOverride guard: an attribute override (@AttributeOverride and friends) targets a property inherited from a real @Entity superclass (not a mapped superclass). JPA only allows overriding fields of mapped superclasses when no intervening entity inherits them, so this override is illegal in the subclass.

Solutions

  1. Remove the override annotation from the subclass; the inherited property may not be overridden there.
Defensive patterns

Strategy: validation

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/883c7b7ed478f347. Report an issue: GitHub.

Appendix: source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java:318

					superEntity,
					usage.name(),
					clazzToProcess,
					AttributeOverride.class
			) );
		}
	}

	/**
	 * The rule is that an entity can override a field declared by a @MappedSuperclass
	 * if there is no intervening entity which also inherits the field. A wrinkle is
	 * that a mapped superclass can occur in between the root class and a subclass of
	 * an entity hierarchy, and then the subclass can override fields declared by the
	 * mapped superclass even though it cannot override any fields of the root class.
	 */
	private static void checkOverride(
			PersistentClass superEntity, String name, ClassDetails clazzToProcess, Class<?> overrideClass) {
		if ( superEntity.hasProperty( root(name) ) ) {
			throw new AnnotationException("Property '" + name
					+ "' is inherited from entity '" + superEntity.getEntityName()
					+ "' and may not be overridden using '@" + overrideClass.getSimpleName()
					+ "' in entity subclass '" + clazzToProcess.getName() + "'");
		}
	}

	private static void bindSoftDelete(
			ClassDetails classDetails,
			RootClass rootClass,
			MetadataBuildingContext context) {
		// todo (soft-delete) : do we assume all package-level registrations are already available?
		//		or should this be a "second pass"?

		final var softDelete = extract( SoftDelete.class, classDetails, context );
		if ( softDelete != null ) {
			SoftDeleteHelper.bindSoftDeleteIndicator(
					softDelete,
					rootClass,

View on GitHub (pinned to fad1729dce)