How can I express literal true
and literal false
in JPA's Criteria API?
I'm looking for something like Predicate alwaysTrue = CriterialBuilder.DefaultLiterals.TRUE
(analogous to java.lang.Boolean.TRUE
).
To get an always true Predicate
instance, use criteriaBuilder.and()
.
To get an always false Predicate
instance, use criteriaBuilder.or()
.
CriteriaBuilder#conjunction() returns a TRUE predicate.
CriteriaBuilder#disjunction() returns a FALSE predicate.
/** * Create a conjunction (with zero conjuncts). * A conjunction with zero conjuncts is true. * * @return and predicate */ Predicate conjunction(); /** * Create a disjunction (with zero disjuncts). * A disjunction with zero disjuncts is false. * * @return or predicate */ Predicate disjunction();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With