Ref : http://stackoverflow.com/questions/9262413/hibernate-dynamic-order
For example, if there is a customize ordering in enum or a specific field.
We can use “Case when ? else ? end” syntax in order by.
(Supported in JPA)
SELECT o
FROM Cat o
ORDER BY CASE o.name WHEN ‘Tom’ THEN 0 ELSE 1 END