I am trying to sort the result of my query by equality expression like
ORDER BY (x = y) ASC
But I keep getting unexpected token =. I even tried things like
ORDER BY COUNT(x = y) ASC
but with no success either: expecting CLOSE, found '='
Is there a way to achieve this with JPQL? Thanks
No, it will not work that way with JPQL. It is not possible, because
x=yis not orderablex=yis not part of SELECT clause.In JPA 2.0 specification this is told with following words:
What you can try is to use CASE in SELECT clause to construct numeric attribute and use that in ORDER BY.