CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<E> query = criteriaBuilder.createQuery(clazz);
Root<E> from = query.from(clazz);
query.select(from.alias("p"));
query.where(criteriaBuilder.and(criteriaBuilder.equal(from.get(fieldName), name),
criteriaBuilder.gt((Expression) from.get("age"), Integer.parseInt(minVal)),
criteriaBuilder.lt((Expression) from.get("age"), Integer.parseInt(maxVal))));
// // // find by name, age clause
TypedQuery<E> q = em.createQuery(query);
List<E> results = q.getResultList();