-->
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: Ordering a query by a Aggregate column
PostPosted: Wed Jun 06, 2007 12:33 pm 
Newbie

Joined: Tue Jun 05, 2007 10:54 am
Posts: 3
Location: Brasil
Hi folks, I´m with a problem to perform a order by in a query like this :

" select count(distinct cli.codCli) from OrdVis "

I want to order this query in a descendant order, but I can´t. I´ve tried to use a Alias to this "column" but Hibernate does not "translate" it (It uses the default naming to the column, e.g col_0_0) and throws a exception when a execute it.

I tried to use a SortedMap too, but it orders the result in a ascendant way.

Do I have to implement a Comparator ? Or there is some easier way to do this ?


Thanks




Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3.2


Name and version of the database you are using: Oracle 9i

_________________
Eduardo Carneiro


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 06, 2007 10:24 pm 
Senior
Senior

Joined: Sat Aug 19, 2006 6:31 pm
Posts: 139
Maybe this will help you.

http://www.hibernate.org/hib_docs/v3/re ... l-ordering

_________________
Don't forget to rate the reply if it helps..:)

Budyanto


Top
 Profile  
 
 Post subject: Not in this case
PostPosted: Thu Jun 07, 2007 8:25 am 
Newbie

Joined: Tue Jun 05, 2007 10:54 am
Posts: 3
Location: Brasil
Budy, I´ve seen the documentation, but , there are just a few examples ordering queries with properties. In my case, I´m selecting just a aggregate column.

I´ve seen some other examples with "count columns", and maybe the problem is with that distinct (inside the count). Something like

"Select count(cli.codCli) from OrdVis order by count(cli.codCli)" , and that just runs fine ...

Any suggestions ?

Thanks

_________________
Eduardo Carneiro


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.