Reputation: 15
How can I use the "order by" clause with "asc nulls first"?
This is my code:
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<MyClassModel> query = builder.createQuery(MyClassModel.class);
//esprToOrder is a Expression<?> istance that containing the sort field...
query.orderBy(builder.asc(esprToOrder));
TypedQuery<MyClassModel> myQ = em.createQuery(query);
List<MyClassModel> myList = myQ.getResultList();
myList doesn't contain any records with null field sort...
Upvotes: 0
Views: 1827
Reputation: 11531
JPA doesn't support specification of "NULLS FIRST|LAST". Some implementations may allow it (by casting to allow extra methods), but it's not part of the JPA spec.
Upvotes: 4