hibernate/hibernate-orm · error · MappingException
Entity [%s] did not define an identifier
Error message
Entity [%s] did not define an identifier
What it means
Error "Entity [%s] did not define an identifier" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/EntityHierarchySourceImpl.java:87
this.caching = Helper.createCaching( entityElement().getCache() );
this.naturalIdCaching = Helper.createNaturalIdCaching(
rootEntitySource.jaxbEntityMapping().getNaturalIdCache()
);
collectedEntityNames.add( rootEntitySource.getEntityNamingSource().getEntityName() );
}
public MappingDocument getRootEntityMappingDocument() {
return rootEntityMappingDocument;
}
private static IdentifierSource interpretIdentifierSource(RootEntitySourceImpl rootEntitySource) {
final JaxbHbmSimpleIdType simpleId = rootEntitySource.jaxbEntityMapping().getId();
final JaxbHbmCompositeIdType compositeId = rootEntitySource.jaxbEntityMapping().getCompositeId();
if ( simpleId == null && compositeId == null ) {
throw new MappingException(
String.format(
Locale.ROOT,
"Entity [%s] did not define an identifier",
rootEntitySource.getEntityNamingSource().getEntityName()
),
rootEntitySource.origin()
);
}
if ( simpleId != null ) {
return new IdentifierSourceSimpleImpl( rootEntitySource );
}
else {
// if we get here, we should have a composite identifier. Just need
// to determine if it is aggregated, or non-aggregated...
if ( compositeId.isMapped() ) {
if ( StringHelper.isEmpty( compositeId.getClazz() ) ) {View on GitHub (pinned to fad1729dce)
Solutions
- Add an <id/> (or <composite-id/>) mapping for the entity in the hbm.xml document.
Example fix
Add an <id/> (or <composite-id/>) mapping for the entity in the hbm.xml document.
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/2dde6002eedfe85b.
Report an issue: GitHub.