hibernate / hibernate-models

An abstraction over "reflection" and annotations
Apache License 2.0
2 stars 5 forks source link

Fix annotation default values extraction #43

Closed dreab8 closed 3 months ago

dreab8 commented 3 months ago

in case of

public @interface JoinTable {
   ....
    ForeignKey inverseForeignKey() default @ForeignKey(ConstraintMode.PROVIDER_DEFAULT);
  ...
}

the value returned by getAttributeMethod().getDefaultValue() is an instance of Annotation, so we need to convert it in a DynaicAnnotationUsage.

When the default value is a multi value

JoinColumn[] joinColumns() default {};

the value returned by getAttributeMethod().getDefaultValue() is an array but we later try to acces it as a list, List<E> AttributeUsage#getList(String name);

dreab8 commented 3 months ago

it seems Arrays.asList( defaultValue ) is not the correct way to convert array default values to a list, it causes an UnsupportException when trying to add a new element to the list.