Georg Echterling (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiOTY0OGUwNDJm...
) / Improvement (
https://hibernate.atlassian.net/browse/HHH-16694?atlOrigin=eyJpIjoiOTY0OG...
) HHH-16694 (
https://hibernate.atlassian.net/browse/HHH-16694?atlOrigin=eyJpIjoiOTY0OG...
) Generated enum columns should respect the enum's intended order (
https://hibernate.atlassian.net/browse/HHH-16694?atlOrigin=eyJpIjoiOTY0OG...
)
Issue Type: Improvement Affects Versions: 6.2.3 Assignee: Unassigned Created: 25/May/2023
05:17 AM Priority: Major Reporter: Georg Echterling (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
For MySQL/MariaDB and PostgreSQL, @Enumerated(EnumType.STRING) attributes are currently
translated into enum(...) types when generated the database schema. MySQL (
https://dev.mysql.com/doc/refman/8.0/en/enum.html#enum-sorting ) , MariaDB (
https://mariadb.com/kb/en/enum/#numeric-index ) , and PostgreSQL (
https://www.postgresql.org/docs/current/datatype-enum.html#id-1.5.7.15.6 ) all specify
that sorting enum columns will use the order in which the enum values were specified in
the enum(...) type. If the enum(...) type was simply generated using the Java enum’s
natural order, this sorting behaviour would match both @Enumerated(EnumType.ORDINAL) and
the Java enum sorting behaviour. However, Dialect#getEnumTypeDeclaration sorts the enum
values alphabatically, removing the intended order.
I.e. enum values should not be sorted alphabetically for databases that support explicit
enum types. If the alphabetical ordering needs to be preserved for some reason, there
should at least be a configuration option to use the intended ordering.
With
https://hibernate.atlassian.net/browse/HHH-16670 , it is currently impossible (in
Hibernate 6.2.3) to use the intended ordering without changing the enum mapping to
ordinal.
(
https://hibernate.atlassian.net/browse/HHH-16694#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16694#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#100225- sha1:0428b75 )