You said:
If you also select the expression that you want to order by, you could instead order by the select alias.
I'm not 100% sure, but I think the problem is the same in SELECT-clauses, because they will be thrown away too when subselecting. So you have to consider this too, when reworking the strategy in hibernate 6.0. And no, this isn't my actual query. I would like to call a specific database function with the criteria API like "ORDER BY anyDbFunction(entity.name, 'arg1', 'arg2')". I just came up with the CONCAT-example to make it reproducible. Furthermore, I had the same problem when ordering some enum-like database fields in a specific order using a SELECT-CASE: ORDER BY CASE WHEN entity.CATEGORY='Foo' THEN 0 WHEN entity.CATEGORY='Bar' THEN 1 WHEN entity.CATEGORY='Baz' THEN 2 ELSE 3 END ASC Just to give you my real examples, in case you might want to consider it during the rework. But thank you for your support! I'll find a solution |