3
In the system I am developing I am trying to use the criteria to be able to execute a query that I am not able to make work by jpql, so I tried to execute according to the material I had getting to this code.
CriteriaBuilder crite = em.getCriteriaBuilder();
CriteriaQuery<Peso> query = crite.createQuery(Peso.class);
Root<Peso> root = query.from(Peso.class);
Path<String> pathStatus = root.<Mapa>get("mapa").<String>get("status");
Predicate predicateStatus = crite.equal(pathStatus, solicitado)
query.where(predicateStatus);
query.orderBy(orders) <<<<<<<<<<<<<<
TypedQuery<Peso> q = em.createQuery(query);
The problem is that I need to order my querry, for that I put the orderby method, (HIGHLIGHTED IN CODE)but it only accepts variables of type Orde[] which I do not know how to use. If anyone could inform me how I perform this ordination I would greatly appreciate.
Thanks! Denis! Your post helped me a lot
– Julio Cesar