hibernate/hibernate-orm · error · AnnotationException
Referenced column '{}' in '@JoinColumn' for {} is not mapped
Error message
Referenced column '{}' in '@JoinColumn' for {} is not mapped by any property of the target entity What it means
Error "Referenced column '{}' in '@JoinColumn' for {} is not mapped by any property of the target entity" thrown in hibernate/hibernate-orm.
Source
Thrown at hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java:497
}
}
// Now we need to line up the properties with the columns in the
// same order they were specified by the @JoinColumn annotations
// this is very tricky because a single property might span
// multiple columns.
// TODO: For now we only consider the first property that matched
// each column, but this means we will reject some mappings
// that could be made to work for a different choice of
// properties (it's also not very deterministic)
final List<Property> orderedProperties = new ArrayList<>();
int lastPropertyColumnIndex = 0;
Property currentProperty = null;
for ( Column column : orderedColumns ) {
final Set<Property> properties = columnsToProperty.get( column );
if ( properties.isEmpty() ) {
// no property found which maps to this column
throw new AnnotationException( "Referenced column '" + column.getName()
+ "' in '@JoinColumn' for " + associationMessage( associatedEntity, columns )
+ " is not mapped by any property of the target entity" );
}
for ( Property property : properties ) {
if ( property == currentProperty ) {
// we have the next column of the previous property
if ( !property.getColumns().get( lastPropertyColumnIndex ).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 for association "
+ associationMessage( associatedEntity, columns ) );
}
lastPropertyColumnIndex++;
if ( lastPropertyColumnIndex == currentProperty.getColumnSpan() ) {
//we have exhausted the columns in this property
currentProperty = null;
lastPropertyColumnIndex = 0;View on GitHub (pinned to fad1729dce)
Solutions
- Change referencedColumnName to the name of a column mapped by a property of the target entity.
- Or add a mapping for that column on the target entity.
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/63fdf941888b8f2e.
Report an issue: GitHub.