diff --git a/api/src/main/java/jakarta/persistence/criteria/CriteriaBuilder.java b/api/src/main/java/jakarta/persistence/criteria/CriteriaBuilder.java index 07d8a321..9c5d009f 100644 --- a/api/src/main/java/jakarta/persistence/criteria/CriteriaBuilder.java +++ b/api/src/main/java/jakarta/persistence/criteria/CriteriaBuilder.java @@ -266,6 +266,14 @@ public interface CriteriaBuilder { */ Predicate and(Predicate... restrictions); + /** + * Create a conjunction of the given restriction predicates. + * A conjunction of zero predicates is true. + * @param restrictions a list of zero or more restriction predicates + * @return and predicate + */ + Predicate and(List restrictions); + /** * Create a disjunction of the given boolean expressions. * @param x boolean expression @@ -282,6 +290,14 @@ public interface CriteriaBuilder { */ Predicate or(Predicate... restrictions); + /** + * Create a disjunction of the given restriction predicates. + * A disjunction of zero predicates is false. + * @param restrictions a list of zero or more restriction predicates + * @return or predicate + */ + Predicate or(List restrictions); + /** * Create a negation of the given restriction. * @param restriction restriction expression diff --git a/api/src/main/java/jakarta/persistence/criteria/CriteriaQuery.java b/api/src/main/java/jakarta/persistence/criteria/CriteriaQuery.java index 8d3a7cbf..58fdfaf2 100644 --- a/api/src/main/java/jakarta/persistence/criteria/CriteriaQuery.java +++ b/api/src/main/java/jakarta/persistence/criteria/CriteriaQuery.java @@ -11,6 +11,7 @@ */ // Contributors: +// Gavin King - 3.2 // Linda DeMichiel - 2.1 // Linda DeMichiel - 2.0 @@ -204,6 +205,19 @@ public interface CriteriaQuery extends AbstractQuery { */ CriteriaQuery where(Predicate... restrictions); + /** + * Modify the query to restrict the query result according + * to the conjunction of the specified restriction predicates. + * Replaces the previously added restriction(s), if any. + * If no restrictions are specified, any previously added + * restrictions are simply removed. + * This method only overrides the return type of the + * corresponding AbstractQuery method. + * @param restrictions a list of zero or more restriction predicates + * @return the modified query + */ + CriteriaQuery where(List restrictions); + /** * Specify the expressions that are used to form groups over * the query results. @@ -254,6 +268,20 @@ public interface CriteriaQuery extends AbstractQuery { */ CriteriaQuery having(Predicate... restrictions); + /** + * Specify restrictions over the groups of the query + * according the conjunction of the specified restriction + * predicates. + * Replaces the previously added having restriction(s), if any. + * If no restrictions are specified, any previously added + * restrictions are simply removed. + * This method only overrides the return type of the + * corresponding AbstractQuery method. + * @param restrictions a list of zero or more restriction predicates + * @return the modified query + */ + CriteriaQuery having(List restrictions); + /** * Specify the ordering expressions that are used to * order the query results. diff --git a/spec/src/main/asciidoc/appendixes.adoc b/spec/src/main/asciidoc/appendixes.adoc index 6e2ab49e..b499a3f3 100644 --- a/spec/src/main/asciidoc/appendixes.adoc +++ b/spec/src/main/asciidoc/appendixes.adoc @@ -110,7 +110,9 @@ Added `||` string concatenation operator Added _getSingleResultOrNull()_ to _Query_, _TypedQuery_, _StoredProcedureQuery_ -Added _concat()_ overload accepting list of expressions to _CriteriaBuilder_ +Overload _concat()_ to accept list of expressions in _CriteriaBuilder_ + +Overload _where()_, _having()_, _and()_, and _or()_ to accept _List_ in _CriteriaQuery_ and _CriteriaBuilder_ Made the _name_ member of _TableGenerator_ and _SequenceGenerator_ optional