{"record":{"id":"8ad48863525b6607","repo":"hibernate/hibernate-orm","slug":"target-property-has-columns-which-must-be","errorCode":null,"errorMessage":"Target property '{}' has {} columns which must be referenced by a '@JoinColumn' for {} (every column mapped by '{}' must occur exactly once as a 'referencedColumnName', and in the correct order)","messagePattern":"Target property '(.+?)' has (.+?) columns which must be referenced by a '@JoinColumn' for (.+?) \\(every column mapped by '(.+?)' must occur exactly once as a 'referencedColumnName', and in the correct order\\)","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java","lineNumber":520,"sourceCode":"\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;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if ( currentProperty != null ) {\n\t\t\t\t\t// we didn't use up all the columns of the previous property\n\t\t\t\t\tthrow new AnnotationException( \"Target property '\" + property.getName() + \"' has \"\n\t\t\t\t\t\t\t+ property.getColumnSpan() + \" columns which must be referenced by a '@JoinColumn' for \"\n\t\t\t\t\t\t\t+ associationMessage( associatedEntity, columns )\n\t\t\t\t\t\t\t+ \" (every column mapped by '\" + property.getName()\n\t\t\t\t\t\t\t+ \"' must occur exactly once as a 'referencedColumnName', and in the correct order)\" );\n\t\t\t\t}\n\t\t\t\telse if ( orderedProperties.contains( property ) ) {\n\t\t\t\t\t// we already used up all the columns of this property\n\t\t\t\t\tthrow new AnnotationException( \"Target property '\" + property.getName() + \"' has only \"\n\t\t\t\t\t\t\t+ property.getColumnSpan() + \" columns which may be referenced by a '@JoinColumn' for \"\n\t\t\t\t\t\t\t+ associationMessage( associatedEntity, columns )\n\t\t\t\t\t\t\t+ \" (each column mapped by '\" + property.getName()\n\t\t\t\t\t\t\t+ \"' may only occur once as a 'referencedColumnName')\" );\n\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\t// we have the first column of a new property\n\t\t\t\t\tif ( property.getColumnSpan() > 1 ) {\n\t\t\t\t\t\tif ( !property.getColumns().get(0).equals( column ) ) {","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java#L502-L538","documentation":"Error \"Target property '{}' has {} columns which must be referenced by a '@JoinColumn' for {} (every column mapped by '{}' must occur exactly once as a 'referencedColumnName', and in the correct order)\" 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":["Add a @JoinColumn referencing each column mapped by the target property exactly once, in the correct order."],"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"}