2

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 ?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.