hibernate jpa criteriabuilder ignore case queries
Posted
by
user373201
on Stack Overflow
See other posts from Stack Overflow
or by user373201
Published on 2011-01-08T19:48:08Z
Indexed on
2011/01/08
19:54 UTC
Read the original article
Hit count: 143
jpa
How to do a like ignore case query using criteria builder. For description property I want to do something like upper(description) like '%xyz%'
I have the following query
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Person> personCriteriaQuery = criteriaBuilder.createQuery(Person.class);
Root<Person> personRoot = personCriteriaQuery.from(Person.class);
personCriteriaQuery.select(personRoot);
personCriteriaQuery.where(criteriaBuilder.like(personRoot.get(Person_.description), "%"+filter.getDescription().toUpperCase()+"%"));
List<Person> pageResults = entityManager.createQuery(personCriteriaQuery).getResultList();
© Stack Overflow or respective owner