hibernate/hibernate-orm · error · AnnotationException
Referenced column '{}' mapped by target property '{}' occurs
Error message
Referenced column '{}' mapped by target property '{}' occurs out of order in the list of '@JoinColumn's What it means
Error "Referenced column '{}' mapped by target property '{}' occurs out of order in the list of '@JoinColumn's" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java:540
+ associationMessage( associatedEntity, columns )
+ " (every column mapped by '" + property.getName()
+ "' must occur exactly once as a 'referencedColumnName', and in the correct order)" );
}
else if ( orderedProperties.contains( property ) ) {
// we already used up all the columns of this property
throw new AnnotationException( "Target property '" + property.getName() + "' has only "
+ property.getColumnSpan() + " columns which may be referenced by a '@JoinColumn' for "
+ associationMessage( associatedEntity, columns )
+ " (each column mapped by '" + property.getName()
+ "' may only occur once as a 'referencedColumnName')" );
}
else {
// we have the first column of a new property
if ( property.getColumnSpan() > 1 ) {
if ( !property.getColumns().get(0).equals( column ) ) {
// the columns have to occur in the right order in the property
throw new AnnotationException("Referenced column '" + column.getName()
+ "' mapped by target property '" + property.getName()
+ "' occurs out of order in the list of '@JoinColumn's");
}
currentProperty = property;
lastPropertyColumnIndex = 1;
}
orderedProperties.add( property );
}
break; // we're only considering the first matching property for now
}
}
return orderedProperties;
}
private static void matchColumnsByProperty(Property property, Map<Column, Set<Property>> columnsToProperty) {
if ( property != null ) {
final String propertyAccessorName = property.getPropertyAccessorName();
if ( !NOOP.getExternalName().equals( propertyAccessorName )View on GitHub (pinned to fad1729dce)
Solutions
- Reorder the @JoinColumn list so the referenced columns match the order of the columns of the referenced property.
When it happens
Trigger: A '@JoinColumn' / 'referencedColumnName' does not line up with the columns mapped by the target entity.
Common situations: Composite foreign keys, associations to entities with secondary tables, or reordered/duplicated referencedColumnName values across multiple @JoinColumn declarations.
AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22).
Data as JSON: /api/errors/5172d0a358074ee9.
Report an issue: GitHub.