public interface IntStream extends ExprStream<Integer,Expression<Integer>>
SearchStream containing Integer values.QueryStream.Builder| Modifier and Type | Method and Description |
|---|---|
<R> IntStream |
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.
|
DoubleStream |
asDoubleStream() |
LongStream |
asLongStream() |
DoubleValue |
average() |
IntStream |
bind(Ref<Integer,? super Expression<Integer>> ref)
Bind an unbound reference to the items in this stream.
|
<X2,S2 extends Selection<X2>> |
bind(Ref<X2,? super S2> ref,
Function<? super Expression<Integer>,? extends S2> refFunction)
Bind an unbound reference to the result of applying the given function to the items in this stream.
|
IntStream |
distinct()
Suppress duplicates.
|
IntStream |
filter(Function<? super Expression<Integer>,? extends Expression<Boolean>> predicateBuilder)
Filter results using the boolean expression produced by the given function.
|
IntValue |
findAny()
Find any instance in the stream.
|
IntValue |
findFirst()
Find the first instance in the stream.
|
IntValue |
findSingle()
Find the only instance in the stream.
|
IntStream |
groupBy(Function<? super Expression<Integer>,? extends Expression<?>> groupFunction)
Apply grouping based on a single expression.
|
IntStream |
groupBy(Ref<?,? extends Expression<?>> ref)
Apply grouping based on an expression reference.
|
IntStream |
groupByMulti(Function<? super Expression<Integer>,? extends List<Expression<?>>> groupFunction)
Apply grouping based on a list of expressions.
|
IntStream |
having(Function<? super Expression<Integer>,? extends Expression<Boolean>> havingFunction)
Add a "having" restriction.
|
IntStream |
limit(int maxSize)
Return this stream truncated to the specified maximum length.
|
IntValue |
max() |
IntValue |
min() |
IntStream |
orderBy(Function<? super Expression<Integer>,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function. |
IntStream |
orderBy(Order... orders)
Order results using the specified
Orders. |
IntStream |
orderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference.
|
IntStream |
orderByMulti(Function<? super Expression<Integer>,? extends List<? extends Order>> orderListFunction)
|
IntStream |
peek(Consumer<? super Expression<Integer>> peeker)
Peek at the items in this stream.
|
IntStream |
skip(int num)
Return this stream with the specified number of initial elements skipped.
|
IntValue |
sum() |
IntStream |
thenOrderBy(Function<? super Expression<Integer>,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function after existing sort. |
IntStream |
thenOrderBy(Order... orders)
Order results using the specified
Orders after existing sort. |
IntStream |
thenOrderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference after existing sort.
|
IntStream |
withFetchGraph(String name)
Configure a fetch graph for this query.
|
IntStream |
withFlushMode(FlushModeType flushMode)
Set the
FlushModeType associated with this query. |
IntStream |
withHint(String name,
Object value)
Associate a hint with this query.
|
IntStream |
withHints(Map<String,Object> hints)
Associate hints with this query.
|
IntStream |
withLoadGraph(String name)
Configure a load graph for this query.
|
IntStream |
withLockMode(LockModeType lockMode)
Set the
LockModeType associated with this query. |
IntStream |
withParam(Parameter<Calendar> parameter,
Calendar value,
TemporalType temporalType)
Bind the value of a query parameter of type
Calendar. |
IntStream |
withParam(Parameter<Date> parameter,
Date value,
TemporalType temporalType)
Bind the value of a query parameter of type
Date. |
<T> IntStream |
withParam(Parameter<T> parameter,
T value)
Bind the value of a query parameter.
|
IntStream |
withParams(Iterable<? extends ParamBinding<?>> params)
Associate parameter bindings with this query.
|
asSubquery, count, countDistinct, exists, fetch, fetch, fetch, fetch, filter, groupBy, orderBy, orderBy, orderBy, thenOrderByallMatch, 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, toQueryconfigureDoubleValue average()
IntValue max()
IntValue min()
IntValue sum()
LongStream asLongStream()
DoubleStream asDoubleStream()
IntStream distinct()
SearchStreamdistinct in interface ExprStream<Integer,Expression<Integer>>distinct in interface SearchStream<Integer,Expression<Integer>>IntStream orderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
SearchStreamReplaces any existing sort ordering.
orderBy in interface ExprStream<Integer,Expression<Integer>>orderBy in interface SearchStream<Integer,Expression<Integer>>ref - previously bound expression referenceasc - true for ascending, false for descendingIntStream orderBy(Function<? super Expression<Integer>,? extends Expression<?>> orderExprFunction, boolean asc)
SearchStreamExpression produced by the given Function.
Replaces any existing sort ordering.
orderBy in interface ExprStream<Integer,Expression<Integer>>orderBy in interface SearchStream<Integer,Expression<Integer>>orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingIntStream orderBy(Order... orders)
SearchStreamOrders.
Replaces any existing sort ordering.
orderBy in interface ExprStream<Integer,Expression<Integer>>orderBy in interface SearchStream<Integer,Expression<Integer>>orders - ordering(s), with higher precedence orderings firstIntStream orderByMulti(Function<? super Expression<Integer>,? extends List<? extends Order>> orderListFunction)
SearchStreamOrder list produced by the given Function.
Replaces any existing sort ordering.
orderByMulti in interface ExprStream<Integer,Expression<Integer>>orderByMulti in interface SearchStream<Integer,Expression<Integer>>orderListFunction - Function that produces the sort ordering given an item expressionIntStream thenOrderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
SearchStreamAdds to any existing sort ordering.
thenOrderBy in interface ExprStream<Integer,Expression<Integer>>thenOrderBy in interface SearchStream<Integer,Expression<Integer>>ref - previously bound expression referenceasc - true for ascending, false for descendingIntStream thenOrderBy(Order... orders)
SearchStreamOrders after existing sort.
Adds to any existing sort ordering.
thenOrderBy in interface ExprStream<Integer,Expression<Integer>>thenOrderBy in interface SearchStream<Integer,Expression<Integer>>orders - ordering(s), with higher precedence orderings firstIntStream thenOrderBy(Function<? super Expression<Integer>,? extends Expression<?>> orderExprFunction, boolean asc)
SearchStreamExpression produced by the given Function after existing sort.
Adds to any existing sort ordering.
thenOrderBy in interface ExprStream<Integer,Expression<Integer>>thenOrderBy in interface SearchStream<Integer,Expression<Integer>>orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingIntStream groupBy(Ref<?,? extends Expression<?>> ref)
SearchStreamAdds to any previously specified groupings.
groupBy in interface ExprStream<Integer,Expression<Integer>>groupBy in interface SearchStream<Integer,Expression<Integer>>ref - previously bound expression referenceIntStream groupBy(Function<? super Expression<Integer>,? extends Expression<?>> groupFunction)
SearchStreamAdds to any previously specified groupings.
groupBy in interface ExprStream<Integer,Expression<Integer>>groupBy in interface SearchStream<Integer,Expression<Integer>>groupFunction - function returning an expression by which to group resultsIntStream groupByMulti(Function<? super Expression<Integer>,? extends List<Expression<?>>> groupFunction)
SearchStreamAdds to any previously specified groupings.
groupByMulti in interface ExprStream<Integer,Expression<Integer>>groupByMulti in interface SearchStream<Integer,Expression<Integer>>groupFunction - function returning a list of expressions by which to group resultsIntStream having(Function<? super Expression<Integer>,? extends Expression<Boolean>> havingFunction)
SearchStreamAdds to any previously specified "having" restrictions.
having in interface ExprStream<Integer,Expression<Integer>>having in interface SearchStream<Integer,Expression<Integer>>havingFunction - function returning a test to apply to grouped resultsIntValue findAny()
SearchStreamfindAny in interface ExprStream<Integer,Expression<Integer>>findAny in interface SearchStream<Integer,Expression<Integer>>NULL if this stream is empty)IntValue findFirst()
SearchStreamfindFirst in interface ExprStream<Integer,Expression<Integer>>findFirst in interface SearchStream<Integer,Expression<Integer>>NULL if this stream is empty)IntValue 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<Integer,Expression<Integer>>findSingle in interface SearchStream<Integer,Expression<Integer>>NULL if this stream is empty)IntStream bind(Ref<Integer,? super Expression<Integer>> ref)
QueryStreambind in interface ExprStream<Integer,Expression<Integer>>bind in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>bind in interface SearchStream<Integer,Expression<Integer>>ref - unbound referencerefIntStream peek(Consumer<? super Expression<Integer>> 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<Integer,Expression<Integer>>peek in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>peek in interface SearchStream<Integer,Expression<Integer>>peeker - peeker into stream<X2,S2 extends Selection<X2>> IntStream bind(Ref<X2,? super S2> ref, Function<? super Expression<Integer>,? extends S2> refFunction)
QueryStreambind in interface ExprStream<Integer,Expression<Integer>>bind in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>bind in interface SearchStream<Integer,Expression<Integer>>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> IntStream 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<Integer,Expression<Integer>>addRoot in interface SearchStream<Integer,Expression<Integer>>R - type of the new query rootref - unbound referencetype - type of the new query rootref to a new query root from typeIntStream filter(Function<? super Expression<Integer>,? extends Expression<Boolean>> predicateBuilder)
QueryStreamAdds to any previously specified filters.
filter in interface ExprStream<Integer,Expression<Integer>>filter in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>filter in interface SearchStream<Integer,Expression<Integer>>predicateBuilder - function mapping this stream's item to a boolean ExpressionIntStream 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<Integer,Expression<Integer>>limit in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>limit in interface SearchStream<Integer,Expression<Integer>>maxSize - maximum number of elements to returnIntStream 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<Integer,Expression<Integer>>skip in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>skip in interface SearchStream<Integer,Expression<Integer>>num - number of elements to skipIntStream withFlushMode(FlushModeType flushMode)
QueryStreamFlushModeType associated with this query.withFlushMode in interface ExprStream<Integer,Expression<Integer>>withFlushMode in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withFlushMode in interface SearchStream<Integer,Expression<Integer>>flushMode - new flush modeQuery.setFlushMode(javax.persistence.FlushModeType)IntStream withLockMode(LockModeType lockMode)
QueryStreamLockModeType associated with this query.withLockMode in interface ExprStream<Integer,Expression<Integer>>withLockMode in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withLockMode in interface SearchStream<Integer,Expression<Integer>>lockMode - new lock modeQuery.setLockMode(javax.persistence.LockModeType)IntStream withHint(String name, Object value)
QueryStreamwithHint in interface ExprStream<Integer,Expression<Integer>>withHint in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withHint in interface SearchStream<Integer,Expression<Integer>>name - name of hintvalue - value of hintQuery.setHint(java.lang.String, java.lang.Object)IntStream withHints(Map<String,Object> hints)
QueryStreamwithHints in interface ExprStream<Integer,Expression<Integer>>withHints in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withHints in interface SearchStream<Integer,Expression<Integer>>hints - hints to addQuery.setHint(java.lang.String, java.lang.Object)<T> IntStream withParam(Parameter<T> parameter, T value)
QueryStreamReplaces any previous binding of the same parameter.
withParam in interface ExprStream<Integer,Expression<Integer>>withParam in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withParam in interface SearchStream<Integer,Expression<Integer>>T - parameter value typeparameter - the parameter to setvalue - parameter valueQuery.setParameter(javax.persistence.Parameter, Object)IntStream withParam(Parameter<Date> parameter, Date value, TemporalType temporalType)
QueryStreamDate.
Replaces any previous binding of the same parameter.
withParam in interface ExprStream<Integer,Expression<Integer>>withParam in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withParam in interface SearchStream<Integer,Expression<Integer>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Date, TemporalType)IntStream withParam(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType)
QueryStreamCalendar.
Replaces any previous binding of the same parameter.
withParam in interface ExprStream<Integer,Expression<Integer>>withParam in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withParam in interface SearchStream<Integer,Expression<Integer>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Calendar, TemporalType)IntStream withParams(Iterable<? extends ParamBinding<?>> params)
QueryStreamReplaces any previous bindings of the same parameters.
withParams in interface ExprStream<Integer,Expression<Integer>>withParams in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withParams in interface SearchStream<Integer,Expression<Integer>>params - bindings to addQuery.setParameter(javax.persistence.Parameter, Object)IntStream withLoadGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.loadgraph", name).
withLoadGraph in interface ExprStream<Integer,Expression<Integer>>withLoadGraph in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withLoadGraph in interface SearchStream<Integer,Expression<Integer>>name - name of load graphIntStream withFetchGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.fetchgraph", name).
withFetchGraph in interface ExprStream<Integer,Expression<Integer>>withFetchGraph in interface QueryStream<Integer,Expression<Integer>,AbstractQuery<?>,CriteriaQuery<Integer>,TypedQuery<Integer>>withFetchGraph in interface SearchStream<Integer,Expression<Integer>>name - name of fetch graphCopyright © 2023. All rights reserved.