By executing this JPQL:
select o.key, count(o.id), sum(o.errors) from MyEntity o
group by o.key
Hibernate commits the following SQL:
select
myentityn0_.key as col_0_0_,
count(myentityn0_.id) as col_1_0_,
sum(myentityn0_.errors) as col_2_0_
from
MYENTITY myentityn0_
group by
myentityn0_.key
But how can I use “order by” in this scenario without using the Hibernate-created column names? If I use as in JPQL, the SQL doesn’t change.
Name the calculation in the
order by: