{"record":{"id":"b39557cfa18eb83b","repo":"hibernate/hibernate-orm","slug":"property-propertyname-of-entity-entityname","errorCode":null,"errorMessage":"Property '<propertyName>' of entity '<entityName>' must have a '@JoinColumn' which references the foreign key column '<logicalColumnName>'","messagePattern":"Property '<propertyName>' of entity '<entityName>' must have a '@JoinColumn' which references the foreign key column '<logicalColumnName>'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java","lineNumber":1358,"sourceCode":"\t\t\t\t\t\tbuildingContext.getBuildingOptions().getPhysicalNamingStrategy();\n\t\t\t\tfinal var database = buildingContext.getMetadataCollector().getDatabase();\n\t\t\t\tfor ( var selectable : referencedValue.getSelectables() ) {\n\t\t\t\t\tif ( selectable instanceof org.hibernate.mapping.Column column ) {\n\t\t\t\t\t\tfinal AnnotatedJoinColumn joinColumn;\n\t\t\t\t\t\tfinal String logicalColumnName;\n\t\t\t\t\t\tfinal String referenceName;\n\t\t\t\t\t\tif ( isExplicitReference ) {\n\t\t\t\t\t\t\tlogicalColumnName = column.getName();\n\t\t\t\t\t\t\treferenceName = normalizedColumnName( column );\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\tlogicalColumnName = null;\n\t\t\t\t\t\t\treferenceName = String.valueOf( index.get() );\n\t\t\t\t\t\t\tindex.getAndIncrement();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tjoinColumn = columnByReferencedName.get( referenceName );\n\t\t\t\t\t\tif ( joinColumn == null && !firstColumn.isNameDeferred() ) {\n\t\t\t\t\t\t\tthrow new AnnotationException(\n\t\t\t\t\t\t\t\t\t\"Property '\" + propertyName\n\t\t\t\t\t\t\t\t\t+ \"' of entity '\" + embeddable.getOwner().getEntityName()\n\t\t\t\t\t\t\t\t\t+ \"' must have a '@JoinColumn' which references the foreign key column '\"\n\t\t\t\t\t\t\t\t\t+ logicalColumnName + \"'\"\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfinal String columnName =\n\t\t\t\t\t\t\t\tjoinColumn == null || joinColumn.isNameDeferred()\n\t\t\t\t\t\t\t\t\t\t? \"tata_\" + column.getName()\n\t\t\t\t\t\t\t\t\t\t: joinColumn.getName();\n\n\t\t\t\t\t\tfinal String physicalName =\n\t\t\t\t\t\t\t\tphysicalNamingStrategy\n\t\t\t\t\t\t\t\t\t\t.toPhysicalColumnName( database.toIdentifier( columnName ),\n\t\t\t\t\t\t\t\t\t\t\t\tdatabase.getJdbcEnvironment() )\n\t\t\t\t\t\t\t\t\t\t.render( database.getDialect() );\n\t\t\t\t\t\tvalue.addColumn( new org.hibernate.mapping.Column( physicalName ) );\n\t\t\t\t\t\tif ( joinColumn != null ) {","sourceCodeStart":1340,"sourceCodeEnd":1376,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EmbeddableBinder.java#L1340-L1376","documentation":"Error \"Property '<propertyName>' of entity '<entityName>' must have a '@JoinColumn' which references the foreign key column '<logicalColumnName>'\" 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 on the property referencing the required foreign key column."],"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"}