Lars Benedetto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5bb1d56...
) *updated* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiY2IzYTc1OTU0...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-17017?atlOrigin=eyJpIjoiY2IzYT...
) HHH-17017 (
https://hibernate.atlassian.net/browse/HHH-17017?atlOrigin=eyJpIjoiY2IzYT...
) Hibernate 6 cannot read VARCHAR column as INT (
https://hibernate.atlassian.net/browse/HHH-17017?atlOrigin=eyJpIjoiY2IzYT...
)
Change By: Lars Benedetto (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5bb1d56...
)
[
https://discourse.hibernate.org/t/hibernate-6-cannot-persist-enum-as-ordi...]
As discussed in this thread, in Hibernate 6 if a column is VARCHAR, but actually contains
integers meant to be mapped with {{@Enumerated(value = EnumType.ORDINAL)}} then you’ll
get an exception caused by it using the char value of the int from the db as the ordinal
index. So a 0 in the db becomes a 48.
{noformat}java.lang.ArrayIndexOutOfBoundsException: Index 48 out of bounds for length 2
at org.hibernate.type.descriptor.java.EnumJavaType.fromInteger(EnumJavaType.java:194)
at org.hibernate.type.descriptor.java.EnumJavaType.fromOrdinal(EnumJavaType.java:211)
at
org.hibernate.type.descriptor.converter.internal.OrdinalEnumValueConverter.toDomainValue(OrdinalEnumValueConverter.java:40)
at
org.hibernate.type.descriptor.converter.internal.OrdinalEnumValueConverter.toDomainValue(OrdinalEnumValueConverter.java:23)
{noformat}
In Hibernate 5, this worked without issue.
I have created a reproducer which I will link to in a few minutes [
https://github.
com/lbenedetto/HHH-17017-Issue-Reproducer|https://github.com/lbenedetto/H...]
(
https://hibernate.atlassian.net/browse/HHH-17017#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-17017#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100233- sha1:da16c62 )