Can anyone point me to how we can pass an order by clause as a named parameter to HQL?
Example which works:
select tb from TransportBooking as tb
an
It can be done like this
order by CASE :orderBy
WHEN 'pato_id' THEN PATO.id
WHEN 'last_update_dt' THEN PATO.last_update_dt
END desc
and you can pass "pato_id" or "last_update_dt" in the setString function like this
q.setString("orderBy", "last_update_dt");
or
q.setString("orderBy", "pato_id");
This works with MS SQL Server, not sure about others.