Hi, I am new to JPA and in particular the CriteriaQuery API. I have a simple CriteriaQuery where I pattern match a simple search String against field entires in a Person entity... i.e. the searchString is always decorated with %searchString%.
The Person object can contain many Record objects. I would like to update my query below to include a similar 'like' pattern match for each applicable field (String) of each element of the List of Records (see pseudo code).
//using MetaModel Expression<List<Records>> records = root.get(Person_.records); Expression<String> param = builder.parameter(String.class); //pseudo code(i think i need something like this here) Predicate myPred = for all records (any record.FIELD LIKE searchString) Path<Integer> status = root.get("status"); criteriaQuery.where( builder.or( builder.like( root.<String>get("name"), searchString ), builder.like( root.<String>get("second_name"), searchString ) //pseuso code (i thin i need to check my predicate here?) builder.like(mypredicate) ), builder.equal(status,value) );
Any help greatly appreciated...