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)). |