HHH-18868 Array annotated with one of @ManyToMany, @OneToMany, or @ElementCollection should be represented with ListAttribute, not SingularAttribute

This commit is contained in:
Čedomir Igaly 2024-12-02 21:10:50 +01:00 committed by Gavin King
parent 212d4b676e
commit a38a300a32
1 changed files with 8 additions and 1 deletions

View File

@ -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