Skip to content

Commit aa8fe5b

Browse files
committed
overload where(), and(), and or() to accept List<Predicate>
see jakartaee#137.
1 parent 4daf494 commit aa8fe5b

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

api/src/main/java/jakarta/persistence/criteria/CriteriaBuilder.java

+16
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ public interface CriteriaBuilder {
266266
*/
267267
Predicate and(Predicate... restrictions);
268268

269+
/**
270+
* Create a conjunction of the given restriction predicates.
271+
* A conjunction of zero predicates is true.
272+
* @param restrictions a list of zero or more restriction predicates
273+
* @return and predicate
274+
*/
275+
Predicate and(List<Predicate> restrictions);
276+
269277
/**
270278
* Create a disjunction of the given boolean expressions.
271279
* @param x boolean expression
@@ -282,6 +290,14 @@ public interface CriteriaBuilder {
282290
*/
283291
Predicate or(Predicate... restrictions);
284292

293+
/**
294+
* Create a disjunction of the given restriction predicates.
295+
* A disjunction of zero predicates is false.
296+
* @param restrictions a list of zero or more restriction predicates
297+
* @return or predicate
298+
*/
299+
Predicate or(List<Predicate> restrictions);
300+
285301
/**
286302
* Create a negation of the given restriction.
287303
* @param restriction restriction expression

api/src/main/java/jakarta/persistence/criteria/CriteriaQuery.java

+13
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ public interface CriteriaQuery<T> extends AbstractQuery<T> {
204204
*/
205205
CriteriaQuery<T> where(Predicate... restrictions);
206206

207+
/**
208+
* Modify the query to restrict the query result according
209+
* to the conjunction of the specified restriction predicates.
210+
* Replaces the previously added restriction(s), if any.
211+
* If no restrictions are specified, any previously added
212+
* restrictions are simply removed.
213+
* This method only overrides the return type of the
214+
* corresponding <code>AbstractQuery</code> method.
215+
* @param restrictions a list of zero or more restriction predicates
216+
* @return the modified query
217+
*/
218+
CriteriaQuery<T> where(List<Predicate> restrictions);
219+
207220
/**
208221
* Specify the expressions that are used to form groups over
209222
* the query results.

0 commit comments

Comments
 (0)