{"record":{"id":"38ec1d7bd02e5ddb","repo":"hibernate/hibernate-orm","slug":"one-to-many-association-propertyname-was-annot","errorCode":null,"errorMessage":"One to many association '<propertyName>' was annotated '@Collate'","messagePattern":"One to many association '<propertyName>' was annotated '@Collate'","errorType":"exception","errorClass":"AnnotationException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/binder/internal/CollateBinder.java","lineNumber":28,"sourceCode":"import org.hibernate.boot.spi.MetadataBuildingContext;\nimport org.hibernate.mapping.Collection;\nimport org.hibernate.mapping.Column;\nimport org.hibernate.mapping.OneToMany;\nimport org.hibernate.mapping.PersistentClass;\nimport org.hibernate.mapping.Property;\nimport org.hibernate.mapping.Value;\n\n/**\n * Handles {@link Collate} annotations.\n *\n * @author Gavin King\n */\npublic class CollateBinder implements AttributeBinder<Collate> {\n\t@Override\n\tpublic void bind(Collate collate, MetadataBuildingContext context, PersistentClass entity, Property property) {\n\t\tfinal Value value = property.getValue();\n\t\tif ( value instanceof OneToMany ) {\n\t\t\tthrow new AnnotationException( \"One to many association '\" + property.getName()\n\t\t\t\t\t+ \"' was annotated '@Collate'\");\n\t\t}\n\t\telse if ( value instanceof Collection ) {\n\t\t\tthrow new AnnotationException( \"Collection '\" + property.getName()\n\t\t\t\t\t+ \"' was annotated '@Collate'\");\n\n\t\t}\n\t\telse {\n\t\t\tfor ( Column column : value.getColumns() ) {\n\t\t\t\tcolumn.setCollation( collate.value() );\n\t\t\t}\n\t\t}\n\t}\n}\n","sourceCodeStart":10,"sourceCodeEnd":43,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/binder/internal/CollateBinder.java#L10-L43","documentation":"@Collate assigns a collation to the mapped columns of an attribute. CollateBinder iterates value.getColumns(), but a @OneToMany association has no column on the owning side (the foreign key lives in the target table), so Hibernate 6.5+ rejects the annotation immediately with an AnnotationException instead of silently ignoring it.","triggerScenarios":"@Collate on a property mapped as @OneToMany (bidirectional mappedBy or unidirectional with @JoinColumn); the attribute binder sees a OneToMany value and throws before any column processing.","commonSituations":"Blanket-applying @Collate to all textual attributes including associations; attempting to control FK column collation from the parent side of the association; migrating columnDefinition strings to @Collate and hitting association properties.","solutions":["Remove @Collate from the @OneToMany property.","To affect a real column, annotate the basic attribute that owns it, or the @ManyToOne side's join column via @Collate / @JoinColumn(columnDefinition = ...).","Set collation at the database level (table/column default) if it must apply to the FK column."],"exampleFix":"// before\n@Entity\npublic class Customer {\n    @Collate(\"und-x-icu\")\n    @OneToMany(mappedBy = \"customer\")\n    private List<Order> orders;\n}\n\n// after\n@Entity\npublic class Customer {\n    @OneToMany(mappedBy = \"customer\")\n    private List<Order> orders;\n}\n\n// collation only on real columns:\n@Entity\npublic class Order {\n    @Collate(\"und-x-icu\")\n    @Column(name = \"code\")\n    private String code;\n}","handlingStrategy":"validation","validationCode":"for (Field f : cls.getDeclaredFields()) {\n    boolean association = f.isAnnotationPresent(jakarta.persistence.OneToMany.class)\n            || f.isAnnotationPresent(jakarta.persistence.ManyToMany.class)\n            || java.util.Collection.class.isAssignableFrom(f.getType());\n    if (f.isAnnotationPresent(org.hibernate.annotations.Collate.class) && association) {\n        throw new IllegalStateException(\"@Collate not allowed on collections: \" + f.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch org.hibernate.AnnotationException during bootstrap; the message names the property. Report as a mapping defect and stop.","preventionTips":["Apply @Collate only to attributes that map to real columns.","For FK collation, annotate the owning @ManyToOne side or the target column.","Codereview annotation sweeps that touch every field."],"tags":["hibernate","jpa","annotations","collation","database","orm-mapping"],"backgroundTag":"jpa-annotation-misplacement","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}