Reputation: 1807
Let's say I have
List cats = sess.createCriteria(Cat.class)
.add( Restrictions.like("name", "F%")
.addOrder( Order.asc("name") )
.list();
Lets presume the cat class has 2 more properties, livesUsed
and livesTotal
.
Is it possible to order ascending the criteria by a query that computes the difference between livesTotal
and livesUsed
without adding a new column to the db_cats with livesDifference
?
How do I implement that ?
Upvotes: 2
Views: 183
Reputation: 1158
Neither the group by clause nor the order by clause can contain arithmetic expressions.
Taken from Hibernate documentation : http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html#queryhql-grouping
Upvotes: 1