Skip to content

Commit a38a300

Browse files
cigalygavinking
authored andcommitted
HHH-18868 Array annotated with one of @manytomany, @onetomany, or @ElementCollection should be represented with ListAttribute, not SingularAttribute
1 parent 212d4b6 commit a38a300

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/MetaAttributeGenerationVisitor.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.List;
2828

2929
import static org.hibernate.processor.util.Constants.ELEMENT_COLLECTION;
30+
import static org.hibernate.processor.util.Constants.LIST_ATTRIBUTE;
3031
import static org.hibernate.processor.util.Constants.MANY_TO_ANY;
3132
import static org.hibernate.processor.util.Constants.MANY_TO_MANY;
3233
import static org.hibernate.processor.util.Constants.MAP_KEY_CLASS;
@@ -70,7 +71,13 @@ private Types typeUtils() {
7071

7172
@Override
7273
public @Nullable AnnotationMetaAttribute visitArray(ArrayType arrayType, Element element) {
73-
return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) );
74+
if ( hasAnnotation( element, MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION ) ) {
75+
return new AnnotationMetaCollection( entity, element, LIST_ATTRIBUTE,
76+
toTypeString(arrayType.getComponentType()) );
77+
}
78+
else {
79+
return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) );
80+
}
7481
}
7582

7683
@Override

0 commit comments

Comments
 (0)