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
If the database contains German words with letters like Fußballschuhe in the column, java will modify the parameter in uppercase method to FUSSBALLSCHUHE and the query will not match. Lowercase will work in this case:
personCriteriaQuery.where(criteriaBuilder.like(
criteriaBuilder.lower(personRoot.get(Person_.description)),
"%"+filter.getDescription().toLowerCase()+"%"));
There is a CriteriaBuilder.upper()
method:
personCriteriaQuery.where(criteriaBuilder.like(
criteriaBuilder.upper(personRoot.get(Person_.description)),
"%"+filter.getDescription().toUpperCase()+"%"));