The following is an extract from a larger Criteria Query:
...
Expression literal = builder.literal((String) "%" + value + "%");
List<Predicate> globalPredicate = new ArrayList<>();
globalPredicate.add(builder.equal(subject.get(Subject_.email), literal));
predicates.add(builder.or(globalPredicate.toArray(new Predicate[globalPredicate.size()])));
...
There is a condition that exists where I explicitly want to pass in null
and find the Subject_.email
who are null
. I tried passing in null
and found that the criteria API wants a nullLiteral(). I tried conditionally replacing literal with nullLiteral() when it was appropriate but then I get nothing returned at all.
What is the best practice way of creating a query that will match null
values for the specified attribute in the DB?