Hi i want to sort in HQL
ORDER BY IF g.groupAdminId=:adminid THEN 1 ELSE 0 END ASC
But it doesn’t work, i want to have all entities where the user is admin first, how can i archieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t believe it is possible to put named parameters outside a
whereclause.It is possible to order according to expressions:
More on
casein HQL docs :For your particular problem (having admins before other users) I suggest making two queries and combining the two lists in Java.
There are other ways around this but I do not like any of them: