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.  [ 3 posts ] 
Author Message
 Post subject: Criteria projections order by
PostPosted: Fri Oct 27, 2006 12:20 pm 
Newbie

Joined: Fri Aug 13, 2004 7:27 pm
Posts: 6
hello all
iam trying to generate a SQL using a hib criteria...the desired sql is


select A.COL1 from Atable A group by COL1 order by count(A.ID) desc

with the criteria i can get both the column A and count but not just the column A. The reason i want only the column A is because i want to use that in a subquery in criteria. Any input is appreciated . thanks

Using hib 3.1.3.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 27, 2006 3:49 pm 
Beginner
Beginner

Joined: Thu Sep 22, 2005 10:48 am
Posts: 30
Location: Rio de Janeiro, Brazil
Use alias to your projection count
Code:
.add( Projections.count("YOUR_ATRIBUTE").as("ALIAS_NAME") )


And add Order of name the your alias
Code:
.addOrder( Order.asc("ALIAS_NAME") )

_________________
Please don't forget to rateME!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 02, 2006 2:56 pm 
Newbie

Joined: Fri Aug 13, 2004 7:27 pm
Posts: 6
i have tried that but it fetches both the column and count like
select col1,count(A.id)....
which i cant feed into a criteria subquery. i tried using a ResultSetTransformer but as expected its applied to resultset after execution of the query not before...


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

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.