{"record":{"id":"2902dd16c73f3d25","repo":"hibernate/hibernate-orm","slug":"collection-propertyname-was-annotated-collat","errorCode":null,"errorMessage":"Collection '<propertyName>' was annotated '@Collate'","messagePattern":"Collection '<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":32,"sourceCode":"import 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":14,"sourceCodeEnd":43,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/binder/internal/CollateBinder.java#L14-L43","documentation":"CollateBinder throws for any Collection-typed value: an @ElementCollection, @ManyToMany, or @OneToMany maps to rows in a collection or target table rather than a simple column of the entity, and Hibernate 6.5+ declines to apply @Collate through such properties. The collation must be declared on the actual element/key columns.","triggerScenarios":"@Collate on a collection property — typically @ElementCollection List<String> tags or @ManyToMany Set<Tag> — during attribute binding the value is a Collection and the binder throws.","commonSituations":"Applying database collation rules to tag/keyword element collections; global annotation sweeps that accidentally hit collection fields; schema reviews demanding collation on collection-table columns.","solutions":["Remove @Collate from the collection property.","Declare collation on the element/key column itself via @Column(columnDefinition = \"varchar(255) collate ...\") on the element mapping.","Or set the collation at the database level (ALTER TABLE / default charset) for the collection table."],"exampleFix":"// before\n@ElementCollection\n@Collate(\"und-x-icu\")\n@Column(name = \"tag\")\nprivate List<String> tags;\n\n// after\n@ElementCollection\n@Column(name = \"tag\", columnDefinition = \"varchar(255) collate und-x-icu\")\nprivate List<String> tags;","handlingStrategy":"validation","validationCode":"for (Field f : cls.getDeclaredFields()) {\n    if (f.isAnnotationPresent(org.hibernate.annotations.Collate.class)\n            && java.util.Collection.class.isAssignableFrom(f.getType())) {\n        throw new IllegalStateException(\"@Collate not allowed on collection: \" + f.getName());\n    }\n}","typeGuard":null,"tryCatchPattern":"Catch org.hibernate.AnnotationException during SessionFactory build; the message identifies the collection property. Abort startup.","preventionTips":["Set collation on element/key columns via @Column(columnDefinition = ...) instead.","Prefer table-level collation defaults for collection tables.","Keep a checklist of Hibernate annotations valid per property kind."],"tags":["hibernate","jpa","annotations","collation","element-collection","orm-mapping"],"backgroundTag":"jpa-annotation-misplacement","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}