- All Superinterfaces:
QueryConfigurer<jakarta.persistence.criteria.CriteriaUpdate<X>,,X, jakarta.persistence.criteria.Root<X>> QueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query>
Stream-like API.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.dellroad.querystream.jpa.QueryStream
QueryStream.Builder -
Method Summary
Modifier and TypeMethodDescriptionBind an unbound reference to the items in this stream.<X2,S2 extends jakarta.persistence.criteria.Selection<X2>>
UpdateStream<X>bind(Ref<X2, ? super S2> ref, Function<? super jakarta.persistence.criteria.Root<X>, ? extends S2> refFunction) Bind an unbound reference to the result of applying the given function to the items in this stream.Filter results using the specified boolean property.filter(Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<Boolean>> predicateBuilder) Filter results using the boolean expression produced by the given function.Get theQueryTypeof this instance.limit(int maxSize) Return this stream truncated to the specified maximum length.Peek at the items in this stream.<Y> UpdateStream<X>set(jakarta.persistence.criteria.Path<Y> path, jakarta.persistence.criteria.Expression<? extends Y> value) Set the property described by the specifiedPathto the value described by the specified expression.<Y> UpdateStream<X>set(jakarta.persistence.criteria.Path<Y> path, Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder) Set the property described by the specifiedPathusing the value expression returned by the given function.<Y,V extends Y>
UpdateStream<X>set(jakarta.persistence.criteria.Path<Y> path, V value) Set the property described by the specifiedPathto the specified value.<Y> UpdateStream<X>set(jakarta.persistence.metamodel.SingularAttribute<? super X, Y> attribute, jakarta.persistence.criteria.Expression<? extends Y> value) Set the property described by the specified attribute to the value described by the specified expression.<Y> UpdateStream<X>set(jakarta.persistence.metamodel.SingularAttribute<? super X, Y> attribute, Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder) Set the property described by the specified attribute using the value expression returned by the given function.<Y,V extends Y>
UpdateStream<X>Set the property described by the specified attribute to the specified value.skip(int num) Return this stream with the specified number of initial elements skipped.intupdate()Build and execute a JPA query based on this instance.withFetchGraph(String name) Configure a fetch graph for this query.withFlushMode(jakarta.persistence.FlushModeType flushMode) Set theFlushModeTypeassociated with this query.Associate a hint with this query.Associate hints with this query.withLoadGraph(String name) Configure a load graph for this query.withLockMode(jakarta.persistence.LockModeType lockMode) Set theLockModeTypeassociated with this query.withParam(jakarta.persistence.Parameter<Calendar> parameter, Calendar value, jakarta.persistence.TemporalType temporalType) Bind the value of a query parameter of typeCalendar.withParam(jakarta.persistence.Parameter<Date> parameter, Date value, jakarta.persistence.TemporalType temporalType) Bind the value of a query parameter of typeDate.<T> UpdateStream<X>withParam(jakarta.persistence.Parameter<T> parameter, T value) Bind the value of a query parameter.withParams(Iterable<? extends ParamBinding<?>> params) Associate parameter bindings with this query.Methods inherited from interface org.dellroad.querystream.jpa.QueryConfigurer
configureMethods inherited from interface org.dellroad.querystream.jpa.QueryStream
getEntityManager, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParams, toCriteriaQuery, toQuery
-
Method Details
-
update
int update()Build and execute a JPA query based on this instance.Ultimately delegates to
Query.executeUpdate()and can throw any exception thrown by that method.- Returns:
- the number of entities updated
-
set
<Y> UpdateStream<X> set(jakarta.persistence.criteria.Path<Y> path, jakarta.persistence.criteria.Expression<? extends Y> value) Set the property described by the specifiedPathto the value described by the specified expression.- Type Parameters:
Y- property type- Parameters:
path- the property to be setvalue- JPA expression for the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifpathis nullIllegalArgumentException- ifvalueis null
-
set
Set the property described by the specifiedPathto the specified value.- Type Parameters:
Y- property typeV- value type- Parameters:
path- the property to be setvalue- the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifpathis null
-
set
<Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X, Y> attribute, jakarta.persistence.criteria.Expression<? extends Y> value) Set the property described by the specified attribute to the value described by the specified expression.- Type Parameters:
Y- property type- Parameters:
attribute- entity attribute to be setvalue- JPA expression for the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifattributeis nullIllegalArgumentException- ifvalueis null
-
set
<Y,V extends Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X, Y> attribute, V value) Set the property described by the specified attribute to the specified value.- Type Parameters:
Y- property typeV- value type- Parameters:
attribute- entity attribute to be setvalue- the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifattributeis null
-
set
<Y> UpdateStream<X> set(jakarta.persistence.criteria.Path<Y> path, Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder) Set the property described by the specifiedPathusing the value expression returned by the given function.- Type Parameters:
Y- property type- Parameters:
path- the property to be setexpressionBuilder- function returning a JPA expression for the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifpathis nullIllegalArgumentException- ifexpressionBuilderis null
-
set
<Y> UpdateStream<X> set(jakarta.persistence.metamodel.SingularAttribute<? super X, Y> attribute, Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<? extends Y>> expressionBuilder) Set the property described by the specified attribute using the value expression returned by the given function.- Type Parameters:
Y- property type- Parameters:
attribute- entity attribute to be setexpressionBuilder- function returning a JPA expression for the value to set- Returns:
- new modified stream
- Throws:
IllegalArgumentException- ifattributeis nullIllegalArgumentException- ifexpressionBuilderis null
-
getQueryType
UpdateType<X> getQueryType()Description copied from interface:QueryStreamGet theQueryTypeof this instance.- Specified by:
getQueryTypein interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Returns:
- associated
QueryType
-
bind
Description copied from interface:QueryStreamBind an unbound reference to the items in this stream. -
bind
<X2,S2 extends jakarta.persistence.criteria.Selection<X2>> UpdateStream<X> bind(Ref<X2, ? super S2> ref, Function<? super jakarta.persistence.criteria.Root<X>, ? extends S2> refFunction) Description copied from interface:QueryStreamBind an unbound reference to the result of applying the given function to the items in this stream.- Specified by:
bindin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Type Parameters:
X2- type of the bound valueS2- criteria type of the bound value- Parameters:
ref- unbound referencerefFunction- function mapping this stream'sSelectionto the reference value- Returns:
- new stream that binds
ref
-
peek
Description copied from interface:QueryStreamPeek at the items in this stream.This is useful in cases where the selection can be modified, e.g., setting join
ONconditions usingJoin.on(). -
filter
UpdateStream<X> filter(jakarta.persistence.metamodel.SingularAttribute<? super X, Boolean> attribute) Description copied from interface:QueryStreamFilter results using the specified boolean property.Adds to any previously specified filters.
-
filter
UpdateStream<X> filter(Function<? super jakarta.persistence.criteria.Root<X>, ? extends jakarta.persistence.criteria.Expression<Boolean>> predicateBuilder) Description copied from interface:QueryStreamFilter results using the boolean expression produced by the given function.Adds to any previously specified filters.
- Specified by:
filterin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
predicateBuilder- function mapping this stream's item to a booleanExpression- Returns:
- new filtered stream
-
limit
Description copied from interface:QueryStreamReturn this stream truncated to the specified maximum length.Due to limitations in the JPA Criteria API, this method is not supported on subquery streams and in general must be specified last (after any filtering, sorting, grouping, joins, etc.).
-
skip
Description copied from interface:QueryStreamReturn this stream with the specified number of initial elements skipped.Due to limitations in the JPA Criteria API, this method is not supported on subquery streams and in general must be specified last (after any filtering, sorting, grouping, joins, etc.).
-
withFlushMode
Description copied from interface:QueryStreamSet theFlushModeTypeassociated with this query.- Specified by:
withFlushModein interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
flushMode- new flush mode- Returns:
- new stream with the specified flush mode configured
- See Also:
-
Query.setFlushMode(jakarta.persistence.FlushModeType)
-
withLockMode
Description copied from interface:QueryStreamSet theLockModeTypeassociated with this query.- Specified by:
withLockModein interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
lockMode- new lock mode- Returns:
- new stream with the specified lock mode configured
- See Also:
-
Query.setLockMode(jakarta.persistence.LockModeType)
-
withHint
Description copied from interface:QueryStreamAssociate a hint with this query.- Specified by:
withHintin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
name- name of hintvalue- value of hint- Returns:
- new stream with the specified hint configured
- See Also:
-
Query.setHint(java.lang.String, java.lang.Object)
-
withHints
Description copied from interface:QueryStreamAssociate hints with this query.- Specified by:
withHintsin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
hints- hints to add- Returns:
- new stream with the specified hints added
- See Also:
-
Query.setHint(java.lang.String, java.lang.Object)
-
withParam
Description copied from interface:QueryStreamBind the value of a query parameter.Replaces any previous binding of the same parameter.
- Specified by:
withParamin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Type Parameters:
T- parameter value type- Parameters:
parameter- the parameter to setvalue- parameter value- Returns:
- new stream with the specified parameter value set
- See Also:
-
Query.setParameter(Parameter, Object)
-
withParam
UpdateStream<X> withParam(jakarta.persistence.Parameter<Date> parameter, Date value, jakarta.persistence.TemporalType temporalType) Description copied from interface:QueryStreamBind the value of a query parameter of typeDate.Replaces any previous binding of the same parameter.
- Specified by:
withParamin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
parameter- the parameter to setvalue- parameter valuetemporalType- temporal type forvalue- Returns:
- new stream with the specified parameter value set
- See Also:
-
Query.setParameter(Parameter, Date, TemporalType)
-
withParam
UpdateStream<X> withParam(jakarta.persistence.Parameter<Calendar> parameter, Calendar value, jakarta.persistence.TemporalType temporalType) Description copied from interface:QueryStreamBind the value of a query parameter of typeCalendar.Replaces any previous binding of the same parameter.
- Specified by:
withParamin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
parameter- the parameter to setvalue- parameter valuetemporalType- temporal type forvalue- Returns:
- new stream with the specified parameter value set
- See Also:
-
Query.setParameter(Parameter, Calendar, TemporalType)
-
withParams
Description copied from interface:QueryStreamAssociate parameter bindings with this query.Replaces any previous bindings of the same parameters.
- Specified by:
withParamsin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
params- bindings to add- Returns:
- new stream with the specified parameter bindings added
- See Also:
-
Query.setParameter(Parameter, Object)
-
withLoadGraph
Description copied from interface:QueryStreamConfigure a load graph for this query.Equivalent to
withHint("jakarta.persistence.loadgraph", name).- Specified by:
withLoadGraphin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
name- name of load graph- Returns:
- new stream with the specified load graph configured
-
withFetchGraph
Description copied from interface:QueryStreamConfigure a fetch graph for this query.Equivalent to
withHint("jakarta.persistence.fetchgraph", name).- Specified by:
withFetchGraphin interfaceQueryStream<X,jakarta.persistence.criteria.Root<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.criteria.CriteriaUpdate<X>, jakarta.persistence.Query> - Parameters:
name- name of fetch graph- Returns:
- new stream with the specified fetch graph configured
-