From a38a300a32b4fc0b4cb02026a588d37e80a727f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Cedomir=20Igaly?= Date: Mon, 2 Dec 2024 21:10:50 +0100 Subject: [PATCH] HHH-18868 Array annotated with one of @ManyToMany, @OneToMany, or @ElementCollection should be represented with ListAttribute, not SingularAttribute --- .../annotation/MetaAttributeGenerationVisitor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java index 37617abdb5..873ea6763b 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java @@ -27,6 +27,7 @@ import javax.tools.Diagnostic; import java.util.List; import static org.hibernate.processor.util.Constants.ELEMENT_COLLECTION; +import static org.hibernate.processor.util.Constants.LIST_ATTRIBUTE; import static org.hibernate.processor.util.Constants.MANY_TO_ANY; import static org.hibernate.processor.util.Constants.MANY_TO_MANY; import static org.hibernate.processor.util.Constants.MAP_KEY_CLASS; @@ -70,7 +71,13 @@ public class MetaAttributeGenerationVisitor extends SimpleTypeVisitor8<@Nullable @Override public @Nullable AnnotationMetaAttribute visitArray(ArrayType arrayType, Element element) { - return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) ); + if ( hasAnnotation( element, MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION ) ) { + return new AnnotationMetaCollection( entity, element, LIST_ATTRIBUTE, + toTypeString(arrayType.getComponentType()) ); + } + else { + return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) ); + } } @Override