In the system I am developing I am trying to use the criteria to be able to execute a query which I am not able to work with jpql, so I tried to execute according to the material that had been getting to that 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 this I put the orderBy method, (HIGHLIGHTED IN THE CODE) but it only accepts variables of type Orde [] which I do not know how to use. If anyone could inform me how to do this ordination I would greatly appreciate it.