hibernate/hibernate-orm · error · AnnotationException

Property '" + getPath( holder, data ) + "' is annotated '@Pa

Error message

Property '" + getPath( holder, data ) + "' is annotated '@Parent' but is not a member of an embeddable class

What it means

@Parent is a Hibernate-specific annotation that marks a back-reference from an embeddable to its owning entity. It is only meaningful when the property holder is a component/embeddable; on a regular entity or plain class there is no parent to bind, so PropertyBinder throws AnnotationException.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java:849

						inSecondPass,
						context,
						inheritanceStatePerClass
				);
			}
		}
	}

	private static boolean alreadyProcessedBySuper(PropertyHolder holder, PropertyData data, EntityBinder binder) {
		return !holder.isComponent()
			&& binder.isPropertyDefinedInSuperHierarchy( data.getPropertyName() );
	}

	private static void handleParentProperty(PropertyHolder holder, PropertyData data, MemberDetails property) {
		if ( holder.isComponent() ) {
			holder.setParentProperty( property.resolveAttributeName() );
		}
		else {
			throw new AnnotationException( "Property '" + getPath( holder, data )
					+ "' is annotated '@Parent' but is not a member of an embeddable class" );
		}
	}

	private static void buildProperty(
			PropertyHolder propertyHolder,
			Nullability nullability,
			PropertyData inferredData,
			EntityBinder entityBinder,
			boolean isIdentifierMapper,
			boolean isComponentEmbedded,
			boolean inSecondPass,
			MetadataBuildingContext context,
			Map<ClassDetails, InheritanceState> inheritanceStatePerClass) {

		final var memberDetails = inferredData.getAttributeMember();

		if ( isPropertyOfRegularEmbeddable( propertyHolder, isComponentEmbedded )

View on GitHub (pinned to fad1729dce)

Solutions

  1. Remove @Parent from the property, or move the property (with @Parent) back into the @Embeddable class.
  2. For a real entity-to-entity reference, use @ManyToOne instead of @Parent.
  3. Verify the holder class is actually used as an embeddable (via @Embedded/@EmbeddedId somewhere).

Example fix

// before: @Parent used on an entity property
@Entity
public class Address {
    @Parent                 // wrong: holder is not an embeddable
    private Person owner;
}

// after: proper use inside an embeddable
@Embeddable
public class Address {
    @Parent
    private Person owner;   // back-reference to the owning entity
}
@Entity
public class Person {
    @Embedded
    private Address address;
}
Defensive patterns

Strategy: validation

Validate before calling

// @Parent only inside embeddables
for (Class<?> entity : annotatedClasses) {
    if (!entity.isAnnotationPresent(Embeddable.class)) {
        for (Field f : entity.getDeclaredFields()) {
            if (f.isAnnotationPresent(Parent.class)) {
                throw new IllegalStateException("@Parent on non-embeddable holder: " + f);
            }
        }
    }
}

Type guard

static boolean isValidParentHolder(Class<?> holder) {
    return holder.isAnnotationPresent(Embeddable.class);
}

Try / catch

try {
    SessionFactory sf = cfg.buildSessionFactory();
} catch (AnnotationException e) {
    throw new IllegalStateException("@Parent misuse: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: @Parent on a field of an @Entity or a non-embeddable class; moving a field with @Parent out of the embeddable during refactoring; using @Parent intending JPA semantics (it is not a JPA annotation) on an entity relationship.

Common situations: Refactoring embeddables and accidentally relocating the back-reference field; misunderstanding @Parent as a parent-child association annotation; migrating embeddable classes between projects where the holder class lost its @Embeddable usage.

Related errors


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/2015da41fa6f3c3d. Report an issue: GitHub.