Skip to content

Commit e54b125

Browse files
cigalybeikov
authored andcommitted
HHH-18858 Array annotated with one of @manytomany, @onetomany, or @ElementCollection should be represented with ListAttribute, not SingularAttribute
1 parent 148995c commit e54b125

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
@@ -29,6 +29,7 @@
2929
import java.util.List;
3030

3131
import static org.hibernate.processor.util.Constants.ELEMENT_COLLECTION;
32+
import static org.hibernate.processor.util.Constants.LIST_ATTRIBUTE;
3233
import static org.hibernate.processor.util.Constants.MANY_TO_ANY;
3334
import static org.hibernate.processor.util.Constants.MANY_TO_MANY;
3435
import static org.hibernate.processor.util.Constants.MAP_KEY_CLASS;
@@ -72,7 +73,13 @@ private Types typeUtils() {
7273

7374
@Override
7475
public @Nullable AnnotationMetaAttribute visitArray(ArrayType arrayType, Element element) {
75-
return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) );
76+
if ( hasAnnotation( element, MANY_TO_MANY, ONE_TO_MANY, ELEMENT_COLLECTION ) ) {
77+
return new AnnotationMetaCollection( entity, element, LIST_ATTRIBUTE,
78+
toTypeString(arrayType.getComponentType()) );
79+
}
80+
else {
81+
return new AnnotationMetaSingleAttribute( entity, element, toArrayTypeString( arrayType, context ) );
82+
}
7683
}
7784

7885
@Override

0 commit comments

Comments
 (0)