-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Cannot order by named selected clause
PostPosted: Mon Aug 25, 2008 5:07 pm 
Newbie

Joined: Mon Aug 25, 2008 4:58 pm
Posts: 1
[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???


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.