Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiYWQxODVkMzM4...
) / New Feature (
https://hibernate.atlassian.net/browse/HHH-16861?atlOrigin=eyJpIjoiYWQxOD...
) HHH-16861 (
https://hibernate.atlassian.net/browse/HHH-16861?atlOrigin=eyJpIjoiYWQxOD...
) HQL ordinal() function (
https://hibernate.atlassian.net/browse/HHH-16861?atlOrigin=eyJpIjoiYWQxOD...
)
Issue Type: New Feature Assignee: Unassigned Components: query-hql Created: 27/Jun/2023
16:10 PM Priority: Major Reporter: Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
)
Several users have complained that in H6 we’re a bit fussier with what you can do with
enum types in HQL.
They would like us to do an automatic type conversion enum → integer when the enum is
mapped ORDINAL.
I’m really not keen on stuff like max(enum) because it seems quite unnatural to me, and is
very sensitive to the details of how the enum is mapped. You can currently write
max(cast(enum as Integer)) which seems fine, but I but verbose, perhaps.
But what if we introduced an explicit function for this, say ordinal(enum) ?
* It would be an explicit type conversion, which I prefer quite strongly.
* We could make it work even for enums mapped STRING , translating it to a case
expression.
* It would be less verbose than cast(enum as Integer).
I doubt that this would be hard to implement.
Hell, we could even provide a similar function for mapping an ORDINAL enum to a string
value, though this would be somewhat less useful.
(
https://hibernate.atlassian.net/browse/HHH-16861#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16861#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#100227- sha1:534ec1c )