Hi.
Is it possible (using Hibernate and JPA2 Criteria Builder [1]) to order by a method's result rather than an entity's member?
public class X { protected X() {} public String member; public String getEvaluatedValue() { // order by return "a status calculated with various members"; } }
What I want to achive is order by the result of getEvaluatedValue(). Is that possible?
Thanks in advanced.
EDIT: Added reply.
I'm not using @Formular, but
EntityManager em = ...; QueryBuilder builder = em.getQueryBuilder(); SomeQueryClass query = builder.createQuery(MyTargetClass.class); query.orderBy(builder.asc(... some code...));
I though it is plain JPA2 and certainly you are right there is no chance to order by dynamic data. But I may be allowed to specify some order-by block with an if-else or whatever statement (defined with my QueryBuilder), won't I?
[1] http://docs.jboss.org/hibernate/entitymanager/3.5/reference/en/html_single/#querycriteria