I’m doing a HQL query as follows, and try to order the list by count column:
select new Persons(count(*) as cnt, p.id, p.name, p.city) group by p.city order by cnt
How ever Hibernate is giving me following error:
Unknown column 'cnt' in 'order clause'
Is there a way to include the city count to person object and get a list that is also ordered by count, or do I have to do it in some other way?
I’m using MySQL as database backend.
Cheers,
OsQu
Ah, it was something so simple that adding count(*) to order by clause. So working solution: