X - stream item typeS - criteria type for stream itemC - configured criteria API query typeC2 - final criteria API query typeQ - JPA query typepublic interface QueryStream<X,S extends Selection<X>,C extends CommonAbstractCriteria,C2 extends C,Q extends Query> extends QueryConfigurer<C,X,S>
Stream-like API.| Modifier and Type | Interface and Description |
|---|---|
static class |
QueryStream.Builder
|
| Modifier and Type | Method and Description |
|---|---|
QueryStream<X,S,C,C2,Q> |
bind(Ref<X,? super S> ref)
Bind an unbound reference to the items in this stream.
|
<X2,S2 extends Selection<X2>> |
bind(Ref<X2,? super S2> ref,
Function<? super S,? extends S2> refFunction)
Bind an unbound reference to the result of applying the given function to the items in this stream.
|
QueryStream<X,S,C,C2,Q> |
filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Filter results using the boolean expression produced by the given function.
|
QueryStream<X,S,C,C2,Q> |
filter(SingularAttribute<? super X,Boolean> attribute)
Filter results using the specified boolean property.
|
EntityManager |
getEntityManager()
Get the
EntityManager associated with this instance. |
int |
getFirstResult()
Get the row offset associated with this query.
|
FlushModeType |
getFlushMode()
Get the
FlushModeType associated with this query. |
Map<String,Object> |
getHints()
Get any hints associated with this query.
|
LockModeType |
getLockMode()
Get the
LockModeType associated with this query. |
int |
getMaxResults()
Get the row limit associated with this query.
|
Set<ParamBinding<?>> |
getParams()
Get any parameter bindings associated with this query.
|
QueryType<X,C,C2,Q> |
getQueryType()
Get the
QueryType of this instance. |
QueryStream<X,S,C,C2,Q> |
limit(int maxSize)
Return this stream truncated to the specified maximum length.
|
static QueryStream.Builder |
newBuilder(EntityManager entityManager)
|
QueryStream<X,S,C,C2,Q> |
peek(Consumer<? super S> peeker)
Peek at the items in this stream.
|
QueryStream<X,S,C,C2,Q> |
skip(int num)
Return this stream with the specified number of initial elements skipped.
|
C2 |
toCriteriaQuery()
Build a criteria API query based on this instance.
|
Q |
toQuery()
Build a fully configured JPA query based on this instance.
|
QueryStream<X,S,C,C2,Q> |
withFetchGraph(String name)
Configure a fetch graph for this query.
|
QueryStream<X,S,C,C2,Q> |
withFlushMode(FlushModeType flushMode)
Set the
FlushModeType associated with this query. |
QueryStream<X,S,C,C2,Q> |
withHint(String name,
Object value)
Associate a hint with this query.
|
QueryStream<X,S,C,C2,Q> |
withHints(Map<String,Object> hints)
Associate hints with this query.
|
QueryStream<X,S,C,C2,Q> |
withLoadGraph(String name)
Configure a load graph for this query.
|
QueryStream<X,S,C,C2,Q> |
withLockMode(LockModeType lockMode)
Set the
LockModeType associated with this query. |
QueryStream<X,S,C,C2,Q> |
withParam(Parameter<Calendar> parameter,
Calendar value,
TemporalType temporalType)
Bind the value of a query parameter of type
Calendar. |
QueryStream<X,S,C,C2,Q> |
withParam(Parameter<Date> parameter,
Date value,
TemporalType temporalType)
Bind the value of a query parameter of type
Date. |
<T> QueryStream<X,S,C,C2,Q> |
withParam(Parameter<T> parameter,
T value)
Bind the value of a query parameter.
|
QueryStream<X,S,C,C2,Q> |
withParams(Iterable<? extends ParamBinding<?>> params)
Associate parameter bindings with this query.
|
configureQueryType<X,C,C2,Q> getQueryType()
QueryType of this instance.QueryTypeEntityManager getEntityManager()
EntityManager associated with this instance.EntityManagerC2 toCriteriaQuery()
Note that due to limitations of the JPA Criteria API, the returned query object lacks information that is configured
on the Query object and not the CriteriaQuery object, including
lock mode, hints, parameters,
row offset and limit, etc.
This information can only be configured on the fully formed Query; use toQuery() instead of this
method to also include that information.
toQuery()Q toQuery()
int getFirstResult()
skip(int),
Query.setFirstResult(int)int getMaxResults()
limit(int),
Query.setMaxResults(int)FlushModeType getFlushMode()
FlushModeType associated with this query.EntityManager setting)Query.setFlushMode(javax.persistence.FlushModeType)QueryStream<X,S,C,C2,Q> withFlushMode(FlushModeType flushMode)
FlushModeType associated with this query.flushMode - new flush modeIllegalArgumentException - if flushMode is nullQuery.setFlushMode(javax.persistence.FlushModeType)LockModeType getLockMode()
LockModeType associated with this query.Query.setLockMode(javax.persistence.LockModeType)QueryStream<X,S,C,C2,Q> withLockMode(LockModeType lockMode)
LockModeType associated with this query.lockMode - new lock modeIllegalArgumentException - if lockMode is nullQuery.setLockMode(javax.persistence.LockModeType)Map<String,Object> getHints()
Query.setHint(java.lang.String, java.lang.Object)QueryStream<X,S,C,C2,Q> withHint(String name, Object value)
name - name of hintvalue - value of hintIllegalArgumentException - if lockMode is nullQuery.setHint(java.lang.String, java.lang.Object)QueryStream<X,S,C,C2,Q> withHints(Map<String,Object> hints)
hints - hints to addIllegalArgumentException - if hints is nullQuery.setHint(java.lang.String, java.lang.Object)Set<ParamBinding<?>> getParams()
Query.setParameter(javax.persistence.Parameter, Object)<T> QueryStream<X,S,C,C2,Q> withParam(Parameter<T> parameter, T value)
Replaces any previous binding of the same parameter.
T - parameter value typeparameter - the parameter to setvalue - parameter valueIllegalArgumentException - if parameter is nullQuery.setParameter(javax.persistence.Parameter, Object)QueryStream<X,S,C,C2,Q> withParam(Parameter<Date> parameter, Date value, TemporalType temporalType)
Date.
Replaces any previous binding of the same parameter.
parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueIllegalArgumentException - if parameter or temporalType is nullQuery.setParameter(javax.persistence.Parameter, Date, TemporalType)QueryStream<X,S,C,C2,Q> withParam(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType)
Calendar.
Replaces any previous binding of the same parameter.
parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueIllegalArgumentException - if parameter or temporalType is nullQuery.setParameter(javax.persistence.Parameter, Calendar, TemporalType)QueryStream<X,S,C,C2,Q> withParams(Iterable<? extends ParamBinding<?>> params)
Replaces any previous bindings of the same parameters.
params - bindings to addIllegalArgumentException - if params or any contained element is nullIllegalArgumentException - if params contains duplicate bindings for the same parameterQuery.setParameter(javax.persistence.Parameter, Object)QueryStream<X,S,C,C2,Q> withLoadGraph(String name)
Equivalent to withHint("javax.persistence.loadgraph", name).
name - name of load graphIllegalArgumentException - if name is invalidQueryStream<X,S,C,C2,Q> withFetchGraph(String name)
Equivalent to withHint("javax.persistence.fetchgraph", name).
name - name of fetch graphIllegalArgumentException - if name is invalidQueryStream<X,S,C,C2,Q> bind(Ref<X,? super S> ref)
ref - unbound referencerefIllegalArgumentException - if ref is already boundIllegalArgumentException - if ref is null<X2,S2 extends Selection<X2>> QueryStream<X,S,C,C2,Q> bind(Ref<X2,? super S2> ref, Function<? super S,? extends S2> refFunction)
X2 - type of the bound valueS2 - criteria type of the bound valueref - unbound referencerefFunction - function mapping this stream's Selection to the reference valuerefIllegalArgumentException - if ref is already boundIllegalArgumentException - if ref or refFunction is nullQueryStream<X,S,C,C2,Q> peek(Consumer<? super S> peeker)
This is useful in cases where the selection can be modified, e.g., setting join ON conditions
using Join.on().
peeker - peeker into streamIllegalArgumentException - if peeker is nullQueryStream<X,S,C,C2,Q> filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Adds to any previously specified filters.
predicateBuilder - function mapping this stream's item to a boolean ExpressionIllegalArgumentException - if predicateBuilder is nullQueryStream<X,S,C,C2,Q> filter(SingularAttribute<? super X,Boolean> attribute)
Adds to any previously specified filters.
attribute - boolean propertyIllegalArgumentException - if attribute is nullQueryStream<X,S,C,C2,Q> limit(int maxSize)
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.).
maxSize - maximum number of elements to returnIllegalArgumentException - if maxSize is negativeQueryStream<X,S,C,C2,Q> skip(int num)
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.).
num - number of elements to skipIllegalArgumentException - if num is negativestatic QueryStream.Builder newBuilder(EntityManager entityManager)
entityManager - entity managerIllegalArgumentException - if entityManager is nullCopyright © 2023. All rights reserved.