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