Gavin King (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%...
) *commented* on HHH-16859 (
https://hibernate.atlassian.net/browse/HHH-16859?atlOrigin=eyJpIjoiMjg3MD...
)
Re: max() doesn't work with Enums (
https://hibernate.atlassian.net/browse/HHH-16859?atlOrigin=eyJpIjoiMjg3MD...
)
It doesn’t make sense because enums aren’t usually ordered types, and because whatever
ordering they may have is lost if you map them with @Enumerated(STRING) , which is the
mapping I think is strongly preferable.
(Persisting an enum as an integer is something that's just a bit too hostile to anyone
else who comes along and tries to make sense of the data.)
Anyway, this isn't just my opinion: if you check sections *4.8.5* and *4.6.7* of the
JPA spec, you’ll see that enums are quite explicitly not valid operands of < or legal
arguments of aggregate functions like max().
Now, sure Hibernate used to accept a lot of not-very-well-typed HQL and let the database
sort it out. We don’t do that anymore, since it was a source of bad error messages and
lots of portability problems. HQL is now much more typesafe, and you’re just going to have
to get used to that.
And, for the record, we’re totally within our rights to make deliberate changes like this
in a major version. That’s why it’s called “Hibernate six” and not “Hibernate five dot
seven”. So drop the attitude please.
On the other hand, I agree that it would be nice to mention this in the migration guide.
I frankly don’t even know what the big deal is when there’s a rather trivial and perfectly
natural workaround: max(cast(enum as Integer)).
(
https://hibernate.atlassian.net/browse/HHH-16859#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16859#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 )