{"record":{"id":"63fdf941888b8f2e","repo":"hibernate/hibernate-orm","slug":"referenced-column-in-joincolumn-for-is","errorCode":null,"errorMessage":"Referenced column '{}' in '@JoinColumn' for {} is not mapped by any property of the target entity","messagePattern":"Referenced column '(.+?)' in '@JoinColumn' for (.+?) is not mapped by any property of the target entity","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java","lineNumber":497,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\t// Now we need to line up the properties with the columns in the\n\t\t// same order they were specified by the @JoinColumn annotations\n\t\t// this is very tricky because a single property might span\n\t\t// multiple columns.\n\t\t// TODO: For now we only consider the first property that matched\n\t\t//       each column, but this means we will reject some mappings\n\t\t//       that could be made to work for a different choice of\n\t\t//       properties (it's also not very deterministic)\n\t\tfinal List<Property> orderedProperties = new ArrayList<>();\n\t\tint lastPropertyColumnIndex = 0;\n\t\tProperty currentProperty = null;\n\t\tfor ( Column column : orderedColumns ) {\n\t\t\tfinal Set<Property> properties = columnsToProperty.get( column );\n\t\t\tif ( properties.isEmpty() ) {\n\t\t\t\t// no property found which maps to this column\n\t\t\t\tthrow new AnnotationException( \"Referenced column '\" + column.getName()\n\t\t\t\t\t\t+ \"' in '@JoinColumn' for \" + associationMessage( associatedEntity, columns )\n\t\t\t\t\t\t+ \" is not mapped by any property of the target entity\" );\n\t\t\t}\n\t\t\tfor ( Property property : properties ) {\n\t\t\t\tif ( property == currentProperty ) {\n\t\t\t\t\t// we have the next column of the previous property\n\t\t\t\t\tif ( !property.getColumns().get( lastPropertyColumnIndex ).equals( column ) ) {\n\t\t\t\t\t\t// the columns have to occur in the right order in the property\n\t\t\t\t\t\tthrow new AnnotationException( \"Referenced column '\" + column.getName()\n\t\t\t\t\t\t\t\t+ \"' mapped by target property '\" + property.getName()\n\t\t\t\t\t\t\t\t+ \"' occurs out of order in the list of '@JoinColumn's for association \"\n\t\t\t\t\t\t\t\t+ associationMessage( associatedEntity, columns ) );\n\t\t\t\t\t}\n\t\t\t\t\tlastPropertyColumnIndex++;\n\t\t\t\t\tif ( lastPropertyColumnIndex == currentProperty.getColumnSpan() ) {\n\t\t\t\t\t\t//we have exhausted the columns in this property\n\t\t\t\t\t\tcurrentProperty = null;\n\t\t\t\t\t\tlastPropertyColumnIndex = 0;","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java#L479-L515","documentation":"Error \"Referenced column '{}' in '@JoinColumn' for {} is not mapped by any property of the target entity\" thrown in hibernate/hibernate-orm.","triggerScenarios":"A '@JoinColumn' / 'referencedColumnName' does not line up with the columns mapped by the target entity.","commonSituations":"Composite foreign keys, associations to entities with secondary tables, or reordered/duplicated referencedColumnName values across multiple @JoinColumn declarations.","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."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}