Open ProIcons opened 2 years ago
This feature was never implemented, but you can implement it if you need it.
Since there are handlings for Enum Values, how is it exactly not implemented? I'm not sure i follow.
Check out the source code and you'll see what is implemented at the moment and why it's not working for you.
When i declare the following type:
and use it like this
it seems that it is completely ignoring the
@Enumerated
and instead it creates an array of thetoString()
values of the enums, instead of thename()
values orordinal()
for enum typesEnumType.String
andEnumType.Ordinal
accordinglyEven if it had as the intended behavior to be always
@Enumerated(EnumType.String)
It is inconsistent since by default on simple fields annotated with@Enumerated(EnumType.STRING)
hibernate is using thename()
method of the enum to persist the values on the database instead of thetoString()
.While this works on persisting the object to the database (even though it is using the
toString()
value), on fetching it will fail with anIllegalArgumentException
which is been thrown from theEnum.valueOf()
on https://github.com/vladmihalcea/hibernate-types/blob/d7cc02d550f6d84df4f50a79ced1b71e6ee2a2d8/hibernate-types-52/src/main/java/com/vladmihalcea/hibernate/type/array/internal/ArrayUtil.java#L191since
toString()
might be overridden and not matchname()
any more.