user3431624
user3431624

Reputation: 311

how to criteriabuilder check null

List<Predicate> predicatesList = new ArrayList<>();

predicatesList.add(cb.or((cb.notEqual(from.get(DISPLAY), STRING_NO)), (cb.equal(from.get(DISPLAY), null))));

I got exception while checking this. I what to check disply not equal to 'N' or display equals null.

(display!='N'or display is NULL)

If I change predicatesList to predicates.add(cb.notEqual(from.get(DISPLAY), STRING_NO)); Then not get error. But I need to check null also.

Upvotes: 5

Views: 15905

Answers (1)

user3431624
user3431624

Reputation: 311

I changed it to

predicates.add(cb.or((cb.notEqual(from.get(DISPLAY), STRING_NO)), (cb.isNull(from.get(DISPLAY)))));

Now It works fine. Thank you so much for helping me.

Upvotes: 13

Related Questions