Dynamic CriteriaBuilder

I’m trying to make some advanced search using the texfields as in the image. Customer emay enter only few values so the query must be dynamic which means search by only those fields which have values.

I’m struck here ``customerEntityService.list(PageRequest.of(query.getPage(), query.getPageSize()),
(root, query1, cb) → {


Not sure how to build the criteriabuilder only for those fields which have values

The simplest solution would be to instantiate an empty list of Predicate in the beginning and create/add Predicates to the list once a given field is non-blank.