hibernate/hibernate-orm · error · MappingException
Association [%s] for entity [%s] references unmapped class [
Error message
Association [%s] for entity [%s] references unmapped class [%s]
What it means
Error "Association [%s] for entity [%s] references unmapped class [%s]" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java:1633
*/
protected void bindOneToManySecondPass(Map<String, PersistentClass> persistentClasses) {
if ( property == null ) {
throw new AssertionFailure( "Null property" );
}
logOneToManySecondPass();
final var oneToMany =
new org.hibernate.mapping.OneToMany( buildingContext, getCollection().getOwner() );
collection.setElement( oneToMany );
oneToMany.setReferencedEntityName( getElementType().getName() );
oneToMany.setNotFoundAction( notFoundAction );
final String referencedEntityName = oneToMany.getReferencedEntityName();
final var associatedClass = persistentClasses.get( referencedEntityName );
handleJpaOrderBy( collection, associatedClass );
if ( associatedClass == null ) {
throw new MappingException(
String.format( "Association [%s] for entity [%s] references unmapped class [%s]",
propertyName, propertyHolder.getClassName(), referencedEntityName )
);
}
oneToMany.setAssociatedClass( associatedClass );
final var joins = getMetadataCollector().getJoins( referencedEntityName );
foreignJoinColumns.setPropertyHolder( buildPropertyHolder(
associatedClass,
joins,
foreignJoinColumns.getBuildingContext(),
inheritanceStatePerClass
) );
foreignJoinColumns.setJoins( joins );
final var collectionTable =
foreignJoinColumns.hasMappedBy()
? associatedClass.getRecursiveProperty( foreignJoinColumns.getMappedBy() )
.getValue().getTable()View on GitHub (pinned to fad1729dce)
Solutions
- Map the referenced class as an entity (add @Entity and include it in the persistence unit).
- Or fix the association target to an already-mapped class.
When it happens
Trigger: An association or reference targets a type that Hibernate has not mapped as an entity.
Common situations: Missing @Entity on the target class, the class not being scanned into the persistence unit, or a typo in the entity name.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/378e308137ca322d.
Report an issue: GitHub.