|
Hi,
What I am trying to do is retrieve some data using the Criteria method. However I want to order the results by a calculation on some of the fields in the row, a calculation that is never stored in the data objects.
Eg,
I do something like this right now
Criteria c = super.getSession().createCriteria(Listing.class);
if (search.getName() != null) c.add(Restrictions.ilike("name", "%" + search.getName() + "%"));
c.setMaxResults(search.getMaxResults()); return c.list();
But I want to also add in there something that lets by order by the sin of the angle field.
eg,
c.addOrder("sin(angle)");
where sin would use the built in function of mysql.
(I'm not actually using sin but it demonstrates my purposes well).
Any help appreciated!
|