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 a little 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. |
|