Yes you should use cq.where().
Try something like this:
Root<Utente> utente = cq.from(Utente.class);
boolean myCondition = true;
Predicate predicate = cb.equal(utente.get(Utente_.ghost), myCondition);
cq.where(predicate);
Where I used the class of canonical metamodels Utente_, which should be generated automatically. This avoids errors when entering field names and increases type safety. Otherwise you can use
Predicate predicate = cb.equal(utente.get("ghost"), myCondition);
source
share