[b]Hibernate version: 3.2.6.ga[/b]
In Hql, if I name a selected object as something, I cannot use that name as an order by clause. For example, the following HQL does not work:
select rrCase, (select count(note) from Note note where rrCase = note.rrCase) as count from RrCase rrCase order by count
In this case, I am selecting all rrCase's and a count of each rrCase's notes, ordered by those note counts. I realize this particular query can be accomplished by other means but this does serve to demonstrate my point that although I named the selected clause "(select count(note) from Note note where rrCase = note.rrCase)" as "count", I cannot sort by that "count" variable. I have found that if I change the order by clause to read "order by col_1_0_", then it works. However, I do not want to have to figure out what Hibernate's naming convention will be when it renames the selected column. Is there any way around this???
|