{"record":{"id":"df732b922551b68b","repo":"hibernate/hibernate-orm","slug":"unidirectional-onetomany-association-path-i","errorCode":null,"errorMessage":"Unidirectional '@OneToMany' association '<path>' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'","messagePattern":"Unidirectional '@OneToMany' association '<path>' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java","lineNumber":1230,"sourceCode":"\t\t\telse {\n\t\t\t\tif ( property.hasDirectAnnotationUsage( MapKeyColumn.class ) ) {\n\t\t\t\t\tthrow new AnnotationException( \"Association '\"\n\t\t\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t\t\t+ \"' is 'mappedBy' another entity and may not specify a '@MapKeyColumn'\"\n\t\t\t\t\t\t\t+ \" (use '@MapKey' instead)\" );\n\t\t\t\t}\n\t\t\t\tif ( property.hasDirectAnnotationUsage( OrderColumn.class ) ) {\n\t\t\t\t\tthrow new AnnotationException( \"Association '\"\n\t\t\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t\t\t+ \"' is 'mappedBy' another entity and may not specify an '@OrderColumn'\"\n\t\t\t\t\t\t\t+ \" (use '@OrderBy' instead)\" );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\telse if ( oneToMany\n\t\t\t\t&& property.hasDirectAnnotationUsage( OnDelete.class )\n\t\t\t\t&& !hasExplicitJoinColumn() ) {\n\t\t\tthrow new AnnotationException( \"Unidirectional '@OneToMany' association '\"\n\t\t\t\t\t+ qualify( propertyHolder.getPath(), propertyName )\n\t\t\t\t\t+ \"' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'\" );\n\t\t}\n\t}\n\n\tprivate boolean hasExplicitJoinColumn() {\n\t\treturn property.hasDirectAnnotationUsage( JoinColumn.class )\n\t\t\t|| property.hasDirectAnnotationUsage( JoinColumns.class )\n\t\t\t|| property.hasDirectAnnotationUsage( JoinTable.class )\n\t\t\t&& property.getDirectAnnotationUsage( JoinTable.class )\n\t\t\t\t\t\t.joinColumns().length > 0;\n\t}\n\n\tprivate void bindProperty() {\n\t\t//property building\n\t\tfinal var binder = new PropertyBinder();\n\t\tbinder.setName( propertyName );\n\t\tbinder.setValue( collection );","sourceCodeStart":1212,"sourceCodeEnd":1248,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java#L1212-L1248","documentation":"Error \"Unidirectional '@OneToMany' association '<path>' is annotated '@OnDelete' and must explicitly specify a '@JoinColumn'\" 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 an explicit @JoinColumn to the unidirectional @OneToMany annotated @OnDelete.","Or remove @OnDelete from the association."],"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"}