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.between((Expression) from.get("age"), Integer.parseInt(minVal),
Integer.parseInt(maxVal))));
TypedQuery<E> q = em.createQuery(query);
List<E> results = q.getResultList();