I need to send a query to retrieve values that has a specific group of characters as following:
Lets say I am interested in \'XX\' so it should search for any field
You can use Predicates in criteria... something like this:
public List findByParameter(String key, String value, String orderKey)
CriteriaBuilder builder = this.entityManager.getCriteriaBuilder();
CriteriaQuery criteria = builder.createQuery(this.getClazz());
Root root = criteria.from(Name.getClass());
criteria.select(root);
List predicates = new ArrayList();
predicates.add(builder.equal(root.get(key), value));
criteria.where(predicates.toArray(new Predicate[predicates.size()]));
if (orderKey!=null && !orderKey.isEmpty()) {
criteria.orderBy(builder.asc(root.get(orderKey)));
}
result = this.entityManager.createQuery(criteria).getResultList();
return result;
}