My sql query is something like
Select * from tableA order by FIELD('ID', 3, 5, 2)
How do I implement this in JPA
using criteria builder
?
EDIT
List<Integer> ordList = new ArrayList<Integer>();
ordList.add(3);
ordList.add(5);
ordList.add(2);
public List<Order> getOrderBys(CriteriaBuilder cb, Root<?> root) {
List<Order> orders = new ArrayList<Order>();
orders.add(cb.function("FIELD", Integer.class, root.get("id"), ordList));
return orders;
}
Above is my function which gives list of oders, I want to add only one order same as above sql query. How can I add/call that function in orders.add()
method? The above method gives error.