-->
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: order by "set is empty"
PostPosted: Thu Feb 12, 2009 6:55 am 
Newbie

Joined: Thu Feb 12, 2009 6:27 am
Posts: 1
I want to sort the sql result showing first all the users who have a certificate (ordered by login) then all users without certificates. I

This order by clause sorts by the set size. It works but I do not want users with more certificates to appear first.
Code:
ORDER BY  p.user.certificates.size DESC, p.user.lastLogin DESC


in SQL that becomes

Code:
(select count(certificat7_.user_id) from certificate_info certificat7_ where user1_.id=certificat7_.user_id) DESC, user1_.last_login DESC


In sql I would just add a "> 0" to make it a boolean.

Code:
(select count(certificat7_.user_id) from certificate_info certificat7_ where user1_.id=certificat7_.user_id) > 0 DESC, user1_.last_login DESC


I tried to find this as an HQL-example in the docu and in the forum , but without luck. Adding the "> 0" to hql leads to :

Code:
org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: > near line 1, column 281


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.