CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
CriteriaQuery<Person> personQuery = criteriaBuilder.createQuery(Person.class);
Root<Person> from = personQuery.from(Person.class);
personQuery.select(from.alias("p"));
personQuery.where(criteriaBuilder.and(criteriaBuilder.equal(from.get("personName"), "'vivek'"),
criteriaBuilder.between((Expression) from.get("age"), 10, 20)));
String actual = CriteriaQueryTranslator.translate(personQuery);
Assert.assertEquals(expected.trim(), actual.trim());
}
@Test