Is it possible (using Hibernate and JPA2 Criteria Builder) to order by a methods result rather than an entities 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 achieve is order by the result of getEvaluatedValue()
. Is that possible?
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?