hibernate/hibernate-orm · error · AnnotationException
Embeddable class '<componentClassName>' may not have a prope
Error message
Embeddable class '<componentClassName>' may not have a property annotated '@Id' since it is used by '<path>' as an '@EmbeddedId'
What it means
Error "Embeddable class '<componentClassName>' may not have a property annotated '@Id' since it is used by '<path>' as an '@EmbeddedId'" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java:367
binder.setMemberDetails( inferredData.getAttributeMember() );
binder.setAccessType( inferredData.getDefaultAccess() );
binder.setEmbedded( isComponentEmbedded );
binder.setHolder( propertyHolder );
binder.setId( isId );
binder.setEntityBinder( entityBinder );
binder.setInheritanceStatePerClass( inheritanceStatePerClass );
binder.setBuildingContext( context );
binder.makePropertyAndBind();
return binder;
}
private static void checkEmbeddedId(
PropertyData inferredData,
PropertyHolder propertyHolder,
String referencedEntityName,
Component embeddable) {
if ( propertyHolder.getPersistentClass().getIdentifier() != null ) {
throw new AnnotationException(
"Embeddable class '" + embeddable.getComponentClassName()
+ "' may not have a property annotated '@Id' since it is used by '"
+ getPath(propertyHolder, inferredData)
+ "' as an '@EmbeddedId'"
);
}
if ( referencedEntityName == null && embeddable.getPropertySpan() == 0 ) {
throw new AnnotationException(
"Embeddable class '" + embeddable.getComponentClassName()
+ "' may not be used as an '@EmbeddedId' by '"
+ getPath(propertyHolder, inferredData)
+ "' because it has no properties"
);
}
}
static Component fillEmbeddable(
PropertyHolder propertyHolder,View on GitHub (pinned to fad1729dce)
Solutions
- Remove @Id from the embeddable property, or stop using the embeddable as an @EmbeddedId.
When it happens
Trigger: A composite identifier mapping (@IdClass/@EmbeddedId/@MapsId) does not match the entity's persistent properties.
Common situations: Composite primary keys where the id class properties, their types, or @MapsId values drift out of sync with the entity, or an embeddable with inheritance is reused as an id.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/1558e37e1fc61888.
Report an issue: GitHub.