I\'m trying to use Criteria API in my new project:
public List findEmps(String name) {
CriteriaBuilder cb = em.getCriteriaBuilder();
I tried all the proposals and although it did not give an error, it did not recover anything if I did not put all the expected text, in the end what was proposed by user3077341 worked for me but with the variant that I use '%' instead of "%", the like worked perfect.
List predicates = new ArrayList();
if(reference!=null){
Predicate condition = builder.like(root.get("reference"),'%'+reference+'%');
predicates.add(condition);
}