I have a simple CriteriaQuery where I pattern match a simple search String against field entires in a Person entity... e.g the searchString is always decorated with
Code:
%searchString%
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)
);
The Person object can contain many Record objects. I would like to update my query above to include a similar 'like' pattern match for each applicable field(String) of each element of the List of Records. I obtain the Records like below:
Code:
//using MetaModel
Expression<List<Records>> records = root.get(Person_.records);
Expression<String> param = builder.parameter(String.class);
Any help much appreciated.