I use Hibernate criteria and would like to add an order-by clause that functionally matches this SQL:
order by abs(dateSubmitted - 125234234)
Where dateSubmitted long and the number subtracted from it will be provided by the user (as a date). I am trying to order entries by their "distance" from a date provided by the user.
I tried
criteria.addOrder("abs(dateSubmitted - " + getDateInput() + ")");
but that will not work.
Is it possible? Or will I have to abandon the criteria for HQL? I have successfully done this in HQL, but would like to adhere to the criteria, if possible to ensure consistency.
sql-order-by hibernate criteria
DLaw
source share