public interface PathStream<X,S extends Path<X>> extends ExprStream<X,S>
SearchStream containing items representable as Paths.QueryStream.Builder| Modifier and Type | Method and Description |
|---|---|
<R> PathStream<X,S> |
addRoot(Ref<R,? super Root<R>> ref,
Class<R> type)
Bind an unbound reference to a new query root that will be added to the query.
|
PathStream<X,S> |
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.
|
<Y extends X> |
cast(Class<Y> type)
Map this stream into a stream whose elements are the result of applying the given narrowing cast.
|
PathStream<X,S> |
distinct()
Suppress duplicates.
|
PathStream<X,S> |
fetch(PluralAttribute<? super X,?,?> attribute)
Add a plural fetch join to this stream.
|
PathStream<X,S> |
fetch(PluralAttribute<? super X,?,?> attribute,
JoinType joinType)
Add a plural fetch join to this stream.
|
PathStream<X,S> |
fetch(SingularAttribute<? super X,?> attribute)
Add a singular fetch inner join to this stream.
|
PathStream<X,S> |
fetch(SingularAttribute<? super X,?> attribute,
JoinType joinType)
Add a singular fetch join to this stream.
|
PathStream<X,S> |
filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Filter results using the boolean expression produced by the given function.
|
PathStream<X,S> |
filter(SingularAttribute<? super X,Boolean> attribute)
Filter results using the specified boolean property.
|
PathValue<X,S> |
findAny()
Find any instance in the stream.
|
PathValue<X,S> |
findFirst()
Find the first instance in the stream.
|
PathValue<X,S> |
findSingle()
Find the only instance in the stream.
|
PathStream<X,S> |
groupBy(Function<? super S,? extends Expression<?>> groupFunction)
Apply grouping based on a single expression.
|
PathStream<X,S> |
groupBy(Ref<?,? extends Expression<?>> ref)
Apply grouping based on an expression reference.
|
PathStream<X,S> |
groupBy(SingularAttribute<? super X,?> attribute)
Apply grouping based on the specified property.
|
PathStream<X,S> |
groupByMulti(Function<? super S,? extends List<Expression<?>>> groupFunction)
Apply grouping based on a list of expressions.
|
PathStream<X,S> |
having(Function<? super S,? extends Expression<Boolean>> havingFunction)
Add a "having" restriction.
|
PathStream<X,S> |
limit(int maxSize)
Return this stream truncated to the specified maximum length.
|
PathStream<X,S> |
orderBy(Function<? super S,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function. |
PathStream<X,S> |
orderBy(Order... orders)
Order results using the specified
Orders. |
PathStream<X,S> |
orderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference.
|
PathStream<X,S> |
orderBy(SingularAttribute<? super X,?> attribute,
boolean asc)
Order results using the specified property.
|
PathStream<X,S> |
orderBy(SingularAttribute<? super X,?> attribute1,
boolean asc1,
SingularAttribute<? super X,?> attribute2,
boolean asc2)
Order results using the specified properties.
|
PathStream<X,S> |
orderBy(SingularAttribute<? super X,?> attribute1,
boolean asc1,
SingularAttribute<? super X,?> attribute2,
boolean asc2,
SingularAttribute<? super X,?> attribute3,
boolean asc3)
Order results using the specified properties.
|
PathStream<X,S> |
orderByMulti(Function<? super S,? extends List<? extends Order>> orderListFunction)
|
PathStream<X,S> |
peek(Consumer<? super S> peeker)
Peek at the items in this stream.
|
PathStream<X,S> |
skip(int num)
Return this stream with the specified number of initial elements skipped.
|
PathStream<X,S> |
thenOrderBy(Function<? super S,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function after existing sort. |
PathStream<X,S> |
thenOrderBy(Order... orders)
Order results using the specified
Orders after existing sort. |
PathStream<X,S> |
thenOrderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference after existing sort.
|
PathStream<X,S> |
thenOrderBy(SingularAttribute<? super X,?> attribute,
boolean asc)
Order results using the specified property after existing sort.
|
PathStream<X,S> |
withFetchGraph(String name)
Configure a fetch graph for this query.
|
PathStream<X,S> |
withFlushMode(FlushModeType flushMode)
Set the
FlushModeType associated with this query. |
PathStream<X,S> |
withHint(String name,
Object value)
Associate a hint with this query.
|
PathStream<X,S> |
withHints(Map<String,Object> hints)
Associate hints with this query.
|
PathStream<X,S> |
withLoadGraph(String name)
Configure a load graph for this query.
|
PathStream<X,S> |
withLockMode(LockModeType lockMode)
Set the
LockModeType associated with this query. |
PathStream<X,S> |
withParam(Parameter<Calendar> parameter,
Calendar value,
TemporalType temporalType)
Bind the value of a query parameter of type
Calendar. |
PathStream<X,S> |
withParam(Parameter<Date> parameter,
Date value,
TemporalType temporalType)
Bind the value of a query parameter of type
Date. |
<T> PathStream<X,S> |
withParam(Parameter<T> parameter,
T value)
Bind the value of a query parameter.
|
PathStream<X,S> |
withParams(Iterable<? extends ParamBinding<?>> params)
Associate parameter bindings with this query.
|
asSubquery, count, countDistinct, existsallMatch, allMatch, anyMatch, anyMatch, flatMap, flatMap, flatMap, flatMapKeys, flatMapValues, getQueryType, getResultList, getResultStream, isEmpty, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, map, map, map, map, mapToDouble, mapToDouble, mapToExpr, mapToFrom, mapToInt, mapToInt, mapToLong, mapToLong, mapToPath, mapToRef, mapToRef, mapToRef, mapToRef, mapToRoot, mapToSelection, noneMatch, noneMatchgetEntityManager, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParams, newBuilder, toCriteriaQuery, toQueryconfigure<Y extends X> PathStream<Y,? extends Path<Y>> cast(Class<Y> type)
Y - narrower typetype - new, narrower item typeCriteriaBuilder.treat()PathStream<X,S> distinct()
SearchStreamPathStream<X,S> orderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
SearchStreamReplaces any existing sort ordering.
PathStream<X,S> orderBy(SingularAttribute<? super X,?> attribute, boolean asc)
SearchStreamReplaces any existing sort ordering.
PathStream<X,S> orderBy(SingularAttribute<? super X,?> attribute1, boolean asc1, SingularAttribute<? super X,?> attribute2, boolean asc2)
SearchStreamReplaces any existing sort ordering.
orderBy in interface ExprStream<X,S extends Path<X>>orderBy in interface SearchStream<X,S extends Path<X>>attribute1 - associated propertyasc1 - true for attribute1 ascending, false for attribute1 descendingattribute2 - associated propertyasc2 - true for attribute2 ascending, false for attribute2 descendingPathStream<X,S> orderBy(SingularAttribute<? super X,?> attribute1, boolean asc1, SingularAttribute<? super X,?> attribute2, boolean asc2, SingularAttribute<? super X,?> attribute3, boolean asc3)
SearchStreamReplaces any existing sort ordering.
orderBy in interface ExprStream<X,S extends Path<X>>orderBy in interface SearchStream<X,S extends Path<X>>attribute1 - associated propertyasc1 - true for attribute1 ascending, false for attribute1 descendingattribute2 - associated propertyasc2 - true for attribute2 ascending, false for attribute2 descendingattribute3 - associated propertyasc3 - true for attribute3 ascending, false for attribute3 descendingPathStream<X,S> orderBy(Function<? super S,? extends Expression<?>> orderExprFunction, boolean asc)
SearchStreamExpression produced by the given Function.
Replaces any existing sort ordering.
orderBy in interface ExprStream<X,S extends Path<X>>orderBy in interface SearchStream<X,S extends Path<X>>orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingPathStream<X,S> orderBy(Order... orders)
SearchStreamOrders.
Replaces any existing sort ordering.
PathStream<X,S> orderByMulti(Function<? super S,? extends List<? extends Order>> orderListFunction)
SearchStreamOrder list produced by the given Function.
Replaces any existing sort ordering.
orderByMulti in interface ExprStream<X,S extends Path<X>>orderByMulti in interface SearchStream<X,S extends Path<X>>orderListFunction - Function that produces the sort ordering given an item expressionPathStream<X,S> thenOrderBy(SingularAttribute<? super X,?> attribute, boolean asc)
SearchStreamAdds to any existing sort ordering.
thenOrderBy in interface ExprStream<X,S extends Path<X>>thenOrderBy in interface SearchStream<X,S extends Path<X>>attribute - associated propertyasc - true for ascending, false for descendingPathStream<X,S> thenOrderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
SearchStreamAdds to any existing sort ordering.
thenOrderBy in interface ExprStream<X,S extends Path<X>>thenOrderBy in interface SearchStream<X,S extends Path<X>>ref - previously bound expression referenceasc - true for ascending, false for descendingPathStream<X,S> thenOrderBy(Order... orders)
SearchStreamOrders after existing sort.
Adds to any existing sort ordering.
thenOrderBy in interface ExprStream<X,S extends Path<X>>thenOrderBy in interface SearchStream<X,S extends Path<X>>orders - ordering(s), with higher precedence orderings firstPathStream<X,S> thenOrderBy(Function<? super S,? extends Expression<?>> orderExprFunction, boolean asc)
SearchStreamExpression produced by the given Function after existing sort.
Adds to any existing sort ordering.
thenOrderBy in interface ExprStream<X,S extends Path<X>>thenOrderBy in interface SearchStream<X,S extends Path<X>>orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingPathStream<X,S> groupBy(Ref<?,? extends Expression<?>> ref)
SearchStreamAdds to any previously specified groupings.
PathStream<X,S> groupBy(SingularAttribute<? super X,?> attribute)
SearchStreamAdds to any previously specified groupings.
PathStream<X,S> groupBy(Function<? super S,? extends Expression<?>> groupFunction)
SearchStreamAdds to any previously specified groupings.
PathStream<X,S> groupByMulti(Function<? super S,? extends List<Expression<?>>> groupFunction)
SearchStreamAdds to any previously specified groupings.
groupByMulti in interface ExprStream<X,S extends Path<X>>groupByMulti in interface SearchStream<X,S extends Path<X>>groupFunction - function returning a list of expressions by which to group resultsPathStream<X,S> having(Function<? super S,? extends Expression<Boolean>> havingFunction)
SearchStreamAdds to any previously specified "having" restrictions.
PathValue<X,S> findAny()
SearchStreamPathValue<X,S> findFirst()
SearchStreamPathValue<X,S> findSingle()
SearchStream
Invoke this method only when you know that the result stream contains at most one value, e.g., when searching
for an object by its value in a field with a unique constraint. If the stream actually contains multiple values,
then invoking any of the "single value" SearchValue methods such as value() or
toOptional() will generate a NonUniqueResultException.
Using this method is preferable to using SearchStream.findFirst() or SearchStream.findAny() for the same purpose, because it
not only actually verifies the uniqueness assumption, but it also makes that assumption clearer in the code.
Example:
final User user = qb.stream(User.class)
.filter(u -> qb.equal(u.get(User_.username), username))
.findSingle()
.orElseThrow(NoSuchUserException::new);
findSingle in interface ExprStream<X,S extends Path<X>>findSingle in interface SearchStream<X,S extends Path<X>>NULL if this stream is empty)PathStream<X,S> fetch(SingularAttribute<? super X,?> attribute)
SearchStream
Equivalent to fetch(attribute, JoinType.INNER).
PathStream<X,S> fetch(SingularAttribute<? super X,?> attribute, JoinType joinType)
SearchStream
Unlike join(), this method does not change the stream's content type.
In other words, this method is used simply to pre-fetch an association, to avoid having to fetch it again
later for each individual element in the stream.
PathStream<X,S> fetch(PluralAttribute<? super X,?,?> attribute)
SearchStream
Equivalent to fetch(attribute, JoinType.INNER).
PathStream<X,S> fetch(PluralAttribute<? super X,?,?> attribute, JoinType joinType)
SearchStream
Unlike join(), this method does not change the stream's content type.
In other words, this method is used simply to pre-fetch an association, to avoid having to fetch it again
later for each individual element in the stream.
PathStream<X,S> bind(Ref<X,? super S> ref)
QueryStreambind in interface ExprStream<X,S extends Path<X>>bind in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>bind in interface SearchStream<X,S extends Path<X>>ref - unbound referencerefPathStream<X,S> peek(Consumer<? super S> peeker)
QueryStream
This is useful in cases where the selection can be modified, e.g., setting join ON conditions
using Join.on().
peek in interface ExprStream<X,S extends Path<X>>peek in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>peek in interface SearchStream<X,S extends Path<X>>peeker - peeker into stream<X2,S2 extends Selection<X2>> PathStream<X,S> bind(Ref<X2,? super S2> ref, Function<? super S,? extends S2> refFunction)
QueryStreambind in interface ExprStream<X,S extends Path<X>>bind in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>bind in interface SearchStream<X,S extends Path<X>>X2 - type of the bound valueS2 - criteria type of the bound valueref - unbound referencerefFunction - function mapping this stream's Selection to the reference valueref<R> PathStream<X,S> addRoot(Ref<R,? super Root<R>> ref, Class<R> type)
SearchStream
To select the new root in a SearchStream, use SearchStream.map(),
providing a Function that returns ref.
Note that this effectively creates an unconstrained (cross product) join with the new root.
Typically there would be some additional restrictions imposed (e.g., via filter())
to relate the new root to the items in the stream.
addRoot in interface ExprStream<X,S extends Path<X>>addRoot in interface SearchStream<X,S extends Path<X>>R - type of the new query rootref - unbound referencetype - type of the new query rootref to a new query root from typePathStream<X,S> filter(SingularAttribute<? super X,Boolean> attribute)
QueryStreamAdds to any previously specified filters.
filter in interface ExprStream<X,S extends Path<X>>filter in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>filter in interface SearchStream<X,S extends Path<X>>attribute - boolean propertyPathStream<X,S> filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
QueryStreamAdds to any previously specified filters.
filter in interface ExprStream<X,S extends Path<X>>filter in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>filter in interface SearchStream<X,S extends Path<X>>predicateBuilder - function mapping this stream's item to a boolean ExpressionPathStream<X,S> limit(int maxSize)
QueryStreamDue 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.).
limit in interface ExprStream<X,S extends Path<X>>limit in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>limit in interface SearchStream<X,S extends Path<X>>maxSize - maximum number of elements to returnPathStream<X,S> skip(int num)
QueryStreamDue 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 in interface ExprStream<X,S extends Path<X>>skip in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>skip in interface SearchStream<X,S extends Path<X>>num - number of elements to skipPathStream<X,S> withFlushMode(FlushModeType flushMode)
QueryStreamFlushModeType associated with this query.withFlushMode in interface ExprStream<X,S extends Path<X>>withFlushMode in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withFlushMode in interface SearchStream<X,S extends Path<X>>flushMode - new flush modeQuery.setFlushMode(javax.persistence.FlushModeType)PathStream<X,S> withLockMode(LockModeType lockMode)
QueryStreamLockModeType associated with this query.withLockMode in interface ExprStream<X,S extends Path<X>>withLockMode in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withLockMode in interface SearchStream<X,S extends Path<X>>lockMode - new lock modeQuery.setLockMode(javax.persistence.LockModeType)PathStream<X,S> withHint(String name, Object value)
QueryStreamwithHint in interface ExprStream<X,S extends Path<X>>withHint in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withHint in interface SearchStream<X,S extends Path<X>>name - name of hintvalue - value of hintQuery.setHint(java.lang.String, java.lang.Object)PathStream<X,S> withHints(Map<String,Object> hints)
QueryStreamwithHints in interface ExprStream<X,S extends Path<X>>withHints in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withHints in interface SearchStream<X,S extends Path<X>>hints - hints to addQuery.setHint(java.lang.String, java.lang.Object)<T> PathStream<X,S> withParam(Parameter<T> parameter, T value)
QueryStreamReplaces any previous binding of the same parameter.
withParam in interface ExprStream<X,S extends Path<X>>withParam in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withParam in interface SearchStream<X,S extends Path<X>>T - parameter value typeparameter - the parameter to setvalue - parameter valueQuery.setParameter(javax.persistence.Parameter, Object)PathStream<X,S> withParam(Parameter<Date> parameter, Date value, TemporalType temporalType)
QueryStreamDate.
Replaces any previous binding of the same parameter.
withParam in interface ExprStream<X,S extends Path<X>>withParam in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withParam in interface SearchStream<X,S extends Path<X>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Date, TemporalType)PathStream<X,S> withParam(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType)
QueryStreamCalendar.
Replaces any previous binding of the same parameter.
withParam in interface ExprStream<X,S extends Path<X>>withParam in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withParam in interface SearchStream<X,S extends Path<X>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Calendar, TemporalType)PathStream<X,S> withParams(Iterable<? extends ParamBinding<?>> params)
QueryStreamReplaces any previous bindings of the same parameters.
withParams in interface ExprStream<X,S extends Path<X>>withParams in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withParams in interface SearchStream<X,S extends Path<X>>params - bindings to addQuery.setParameter(javax.persistence.Parameter, Object)PathStream<X,S> withLoadGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.loadgraph", name).
withLoadGraph in interface ExprStream<X,S extends Path<X>>withLoadGraph in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withLoadGraph in interface SearchStream<X,S extends Path<X>>name - name of load graphPathStream<X,S> withFetchGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.fetchgraph", name).
withFetchGraph in interface ExprStream<X,S extends Path<X>>withFetchGraph in interface QueryStream<X,S extends Path<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>withFetchGraph in interface SearchStream<X,S extends Path<X>>name - name of fetch graphCopyright © 2023. All rights reserved.