Interface SearchStream<X,S extends Selection<X>>
- Type Parameters:
X
- stream item typeS
- criteria type for stream item
- All Superinterfaces:
QueryConfigurer<AbstractQuery<?>,
,X, S> QueryStream<X,
S, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>>
- All Known Subinterfaces:
BooleanValue
,DoubleStream
,DoubleValue
,ExprStream<X,
,S> ExprValue<X,
,S> FromStream<X,
,S> FromValue<X,
,S> IntStream
,IntValue
,LongStream
,LongValue
,PathStream<X,
,S> PathValue<X,
,S> RootStream<X>
,RootValue<X>
,SearchValue<X,
S>
Stream
-like API.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.dellroad.querystream.jpa.QueryStream
QueryStream.Builder
-
Method Summary
Modifier and TypeMethodDescription<R> SearchStream<X,
S> Bind an unbound reference to a new query root that will be added to the query.boolean
allMatch
(SingularAttribute<? super X, Boolean> attribute) Execute this query and return true if the given property is true for every resulting item.boolean
allMatch
(Function<? super S, ? extends Expression<Boolean>> predicateBuilder) Execute this query and return true if the predicate returned by the given function is true for every resulting item.boolean
anyMatch
(SingularAttribute<? super X, Boolean> attribute) Execute this query and return true if any results are found for which the given property is true.boolean
anyMatch
(Function<? super S, ? extends Expression<Boolean>> predicateBuilder) Execute this query and return true if any results are found for which the predicate returned by the given function is true.Bind an unbound reference to the items in this stream.<X2,
S2 extends Selection<X2>>
SearchStream<X,S> Bind an unbound reference to the result of applying the given function to the items in this stream.distinct()
Suppress duplicates.fetch
(PluralAttribute<? super X, ?, ?> attribute) Add a plural fetch join to this stream.fetch
(PluralAttribute<? super X, ?, ?> attribute, JoinType joinType) Add a plural fetch join to this stream.fetch
(SingularAttribute<? super X, ?> attribute) Add a singular fetch inner join to this stream.fetch
(SingularAttribute<? super X, ?> attribute, JoinType joinType) Add a singular fetch join to this stream.filter
(SingularAttribute<? super X, Boolean> attribute) Filter results using the specified boolean property.filter
(Function<? super S, ? extends Expression<Boolean>> predicateBuilder) Filter results using the boolean expression produced by the given function.findAny()
Find any instance in the stream.Find the first instance in the stream.Find the only instance in the stream or null.default <E> FromStream<E,
CollectionJoin<X, E>> flatMap
(CollectionAttribute<? super X, E> attribute) Map this stream to a stream where every item is replaced with the contents of the specified collection.default <E> FromStream<E,
ListJoin<X, E>> flatMap
(ListAttribute<? super X, E> attribute) Map this stream to a stream where every item is replaced with the contents of the specified collection.default <E> FromStream<E,
SetJoin<X, E>> flatMap
(SetAttribute<? super X, E> attribute) Map this stream to a stream where every item is replaced with the contents of the specified collection.default <K> PathStream<K,
Path<K>> flatMapKeys
(MapAttribute<? super X, K, ?> attribute) Map this stream to a stream where every item is replaced with the keys of the specified map.default <V> PathStream<V,
Path<V>> flatMapValues
(MapAttribute<? super X, ?, V> attribute) Map this stream to a stream where every item is replaced with the values of the specified map.Get theQueryType
of this instance.Build and evaluate a JPA query based on this instance and return the result list.Build and evaluate a JPA query based on this instance and return the result stream.groupBy
(SingularAttribute<? super X, ?> attribute) Apply grouping based on the specified property.groupBy
(Function<? super S, ? extends Expression<?>> groupFunction) Apply grouping based on a single expression.groupBy
(Ref<?, ? extends Expression<?>> ref) Apply grouping based on an expression reference.groupByMulti
(Function<? super S, ? extends List<Expression<?>>> groupFunction) Apply grouping based on a list of expressions.having
(Function<? super S, ? extends Expression<Boolean>> havingFunction) Add a "having" restriction.boolean
isEmpty()
Execute this query and return true if no results are found.default <E> FromStream<E,
CollectionJoin<X, E>> join
(CollectionAttribute<? super X, E> attribute) Add a collection inner join to this stream.default <E> FromStream<E,
CollectionJoin<X, E>> join
(CollectionAttribute<? super X, E> attribute, JoinType joinType) Add a collection join to this stream using the specified join type.default <E> FromStream<E,
CollectionJoin<X, E>> join
(CollectionAttribute<? super X, E> attribute, JoinType joinType, Function<? super CollectionJoin<X, E>, ? extends Expression<Boolean>> on) Add a collection join to this stream using the specified join type and ON condition.default <E> FromStream<E,
ListJoin<X, E>> join
(ListAttribute<? super X, E> attribute) Add a list inner join to this stream.default <E> FromStream<E,
ListJoin<X, E>> join
(ListAttribute<? super X, E> attribute, JoinType joinType) Add a list join to this stream using the specified join type.default <E> FromStream<E,
ListJoin<X, E>> join
(ListAttribute<? super X, E> attribute, JoinType joinType, Function<? super ListJoin<X, E>, ? extends Expression<Boolean>> on) Add a list join to this stream using the specified join type and ON condition.default <K,
V> FromStream<V, MapJoin<X, K, V>> join
(MapAttribute<? super X, K, V> attribute) Add a map inner join to this stream.default <K,
V> FromStream<V, MapJoin<X, K, V>> join
(MapAttribute<? super X, K, V> attribute, JoinType joinType) Add a map join to this stream using the specified join type.default <K,
V> FromStream<V, MapJoin<X, K, V>> join
(MapAttribute<? super X, K, V> attribute, JoinType joinType, Function<? super MapJoin<X, K, V>, ? extends Expression<Boolean>> on) Add a map join to this stream using the specified join type and ON condition.default <E> FromStream<E,
SetJoin<X, E>> join
(SetAttribute<? super X, E> attribute) Add a set inner join to this stream.default <E> FromStream<E,
SetJoin<X, E>> join
(SetAttribute<? super X, E> attribute, JoinType joinType) Add a set join to this stream using the specified join type.default <E> FromStream<E,
SetJoin<X, E>> join
(SetAttribute<? super X, E> attribute, JoinType joinType, Function<? super SetJoin<X, E>, ? extends Expression<Boolean>> on) Add a set join to this stream using the specified join type and ON condition.default <Y> FromStream<Y,
From<X, Y>> join
(SingularAttribute<? super X, Y> attribute) Add a singular inner join to this stream.default <Y> FromStream<Y,
From<X, Y>> join
(SingularAttribute<? super X, Y> attribute, JoinType joinType) Add a singular join to this stream using the specified join type.default <Y> FromStream<Y,
From<X, Y>> join
(SingularAttribute<? super X, Y> attribute, JoinType joinType, Function<? super Join<X, Y>, ? extends Expression<Boolean>> on) Add a singular join to this stream using the specified join type and ON condition.limit
(int maxSize) Return this stream truncated to the specified maximum length.default <K,
V, M extends Map<K, V>>
ExprStream<M,Expression<M>> map
(MapAttribute<? super X, K, V> attribute) Map this stream to an associated map property.default <E,
C extends Collection<E>>
ExprStream<C,Expression<C>> map
(PluralAttribute<? super X, C, E> attribute) Map this stream to an associated collection property.default <Y> PathStream<Y,
Path<Y>> map
(SingularAttribute<? super X, Y> attribute) Map this stream to an associated property.default <Y> ExprStream<Y,
Expression<Y>> map
(Class<Y> type, Function<? super S, ? extends Expression<Y>> exprFunction) Map this stream into a stream whose elements are the result of applying the given function.default DoubleStream
mapToDouble
(SingularAttribute<? super X, ? extends Number> attribute) Map this stream to an associated floating point value.default DoubleStream
mapToDouble
(Function<? super S, ? extends Expression<? extends Number>> doubleExprFunction) Map this stream into a stream of double values that are the result of applying the given function.default <Y> ExprStream<Y,
Expression<Y>> mapToExpr
(Class<Y> type, Function<? super S, ? extends Expression<Y>> exprFunction) Map this stream into a stream whose elements are the result of applying the given function.default <Z,
Y> FromStream<Y, From<Z, Y>> Map this stream into a stream whose elements are the result of applying the given function.default IntStream
mapToInt
(SingularAttribute<? super X, ? extends Number> attribute) Map this stream to an associated integer value.default IntStream
mapToInt
(Function<? super S, ? extends Expression<? extends Number>> intExprFunction) Map this stream into a stream of integer values that are the result of applying the given function.default LongStream
mapToLong
(SingularAttribute<? super X, ? extends Number> attribute) Map this stream to an associated long value.default LongStream
mapToLong
(Function<? super S, ? extends Expression<? extends Number>> longExprFunction) Map this stream into a stream of long values that are the result of applying the given function.default <Y> PathStream<Y,
Path<Y>> Map this stream into a stream whose elements are the result of applying the given function.default <Y> ExprStream<Y,
Expression<Y>> Map this stream to a stream whose elements are bound to the supplied expression reference.default <Y> FromStream<Y,
From<?, Y>> Map this stream to a stream whose elements are bound to the supplied from reference.default <Y> PathStream<Y,
Path<Y>> Map this stream to a stream whose elements are bound to the supplied path reference.default <Y> RootStream<Y>
Map this stream to a stream whose elements are bound to the supplied root reference.default <Y> RootStream<Y>
Map this stream into a stream whose elements are the result of applying the given function.default <Y> SearchStream<Y,
Selection<Y>> mapToSelection
(Class<Y> type, Function<? super S, ? extends Selection<Y>> selectionFunction) Map this stream into a stream whose elements are the result of applying the given function.boolean
noneMatch
(SingularAttribute<? super X, Boolean> attribute) Execute this query and return true if no results are found for which the given property is true.boolean
noneMatch
(Function<? super S, ? extends Expression<Boolean>> predicateBuilder) Execute this query and return true if no result are found for which the predicate returned by the given function is true.Order results using the specifiedOrder
s.orderBy
(SingularAttribute<? super X, ?> attribute, boolean asc) Order results using the specified property.orderBy
(SingularAttribute<? super X, ?> attribute1, boolean asc1, SingularAttribute<? super X, ?> attribute2, boolean asc2) Order results using the specified properties.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.orderBy
(Function<? super S, ? extends Expression<?>> orderExprFunction, boolean asc) Order results using theExpression
produced by the givenFunction
.orderBy
(Ref<?, ? extends Expression<?>> ref, boolean asc) Order results using the specified expression reference.orderByMulti
(Function<? super S, ? extends List<? extends Order>> orderListFunction) Peek at the items in this stream.skip
(int num) Return this stream with the specified number of initial elements skipped.thenOrderBy
(Order... orders) Order results using the specifiedOrder
s after existing sort.thenOrderBy
(SingularAttribute<? super X, ?> attribute, boolean asc) Order results using the specified property after existing sort.thenOrderBy
(Function<? super S, ? extends Expression<?>> orderExprFunction, boolean asc) Order results using theExpression
produced by the givenFunction
after existing sort.thenOrderBy
(Ref<?, ? extends Expression<?>> ref, boolean asc) Order results using the specified expression reference after existing sort.withFetchGraph
(String name) Configure a fetch graph for this query.withFlushMode
(FlushModeType flushMode) Set theFlushModeType
associated 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
(LockModeType lockMode) Set theLockModeType
associated with this query.withParam
(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType) Bind the value of a query parameter of typeCalendar
.withParam
(Parameter<Date> parameter, Date value, TemporalType temporalType) Bind the value of a query parameter of typeDate
.<T> SearchStream<X,
S> 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
configure
Methods inherited from interface org.dellroad.querystream.jpa.QueryStream
getEntityManager, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParams, toCriteriaQuery, toQuery
-
Method Details
-
getResultList
Build and evaluate a JPA query based on this instance and return the result list.Delegates to
TypedQuery.getResultList()
and can throw any exception thrown by that method.- Returns:
- result of executed query
- See Also:
-
getResultStream
Build and evaluate a JPA query based on this instance and return the result stream.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Returns:
- result of executed query
- See Also:
-
distinct
SearchStream<X,S> distinct()Suppress duplicates.- Returns:
- a new stream with duplicates removed
-
orderBy
Order results using the specified property.Replaces any existing sort ordering.
- Parameters:
attribute
- associated propertyasc
- true for ascending, false for descending- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- ifattribute
is null
-
orderBy
SearchStream<X,S> orderBy(SingularAttribute<? super X, ?> attribute1, boolean asc1, SingularAttribute<? super X, ?> attribute2, boolean asc2) Order results using the specified properties.Replaces any existing sort ordering.
- Parameters:
attribute1
- associated propertyasc1
- true forattribute1
ascending, false forattribute1
descendingattribute2
- associated propertyasc2
- true forattribute2
ascending, false forattribute2
descending- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- ifattribute1
orattribute2
is null
-
orderBy
SearchStream<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.Replaces any existing sort ordering.
- Parameters:
attribute1
- associated propertyasc1
- true forattribute1
ascending, false forattribute1
descendingattribute2
- associated propertyasc2
- true forattribute2
ascending, false forattribute2
descendingattribute3
- associated propertyasc3
- true forattribute3
ascending, false forattribute3
descending- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- ifattribute1
,attribute2
, orattribute3
is null
-
orderBy
Order results using the specified expression reference.Replaces any existing sort ordering.
- Parameters:
ref
- previously bound expression referenceasc
- true for ascending, false for descending- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- ifref
is null
-
orderBy
Order results using the specifiedOrder
s.Replaces any existing sort ordering.
- Parameters:
orders
- ordering(s), with higher precedence orderings first- Returns:
- a new stream with specified ordering(s)
- Throws:
IllegalArgumentException
- iforders
is null
-
orderBy
SearchStream<X,S> orderBy(Function<? super S, ? extends Expression<?>> orderExprFunction, boolean asc) Order results using theExpression
produced by the givenFunction
.Replaces any existing sort ordering.
- Parameters:
orderExprFunction
-Function
that produces anExpression
to order on given an item expressionasc
- true for ascending, false for descending- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- iforderExprFunction
is null
-
orderByMulti
SearchStream<X,S> orderByMulti(Function<? super S, ? extends List<? extends Order>> orderListFunction) Order results using theOrder
list produced by the givenFunction
.Replaces any existing sort ordering.
- Parameters:
orderListFunction
-Function
that produces the sort ordering given an item expression- Returns:
- a new stream with specified ordering
- Throws:
IllegalArgumentException
- iforderListFunction
is null
-
thenOrderBy
Order results using the specified property after existing sort.Adds to any existing sort ordering.
- Parameters:
attribute
- associated propertyasc
- true for ascending, false for descending- Returns:
- a new stream with specified additional ordering
- Throws:
IllegalArgumentException
- ifattribute
is null
-
thenOrderBy
Order results using the specified expression reference after existing sort.Adds to any existing sort ordering.
- Parameters:
ref
- previously bound expression referenceasc
- true for ascending, false for descending- Returns:
- a new stream with specified additional ordering
- Throws:
IllegalArgumentException
- ifref
is null
-
thenOrderBy
Order results using the specifiedOrder
s after existing sort.Adds to any existing sort ordering.
- Parameters:
orders
- ordering(s), with higher precedence orderings first- Returns:
- a new stream with specified additional ordering(s)
- Throws:
IllegalArgumentException
- iforders
is null
-
thenOrderBy
SearchStream<X,S> thenOrderBy(Function<? super S, ? extends Expression<?>> orderExprFunction, boolean asc) Order results using theExpression
produced by the givenFunction
after existing sort.Adds to any existing sort ordering.
- Parameters:
orderExprFunction
-Function
that produces anExpression
to order on given an item expressionasc
- true for ascending, false for descending- Returns:
- a new stream with specified additional ordering
- Throws:
IllegalArgumentException
- iforderExprFunction
is null
-
groupBy
Apply grouping based on an expression reference.Adds to any previously specified groupings.
- Parameters:
ref
- previously bound expression reference- Returns:
- a new stream with additional grouping
- Throws:
IllegalArgumentException
- ifref
is null
-
groupBy
Apply grouping based on the specified property.Adds to any previously specified groupings.
- Parameters:
attribute
- associated property- Returns:
- a new stream with additional grouping
- Throws:
IllegalArgumentException
- ifattribute
is null
-
groupBy
Apply grouping based on a single expression.Adds to any previously specified groupings.
- Parameters:
groupFunction
- function returning an expression by which to group results- Returns:
- a new stream with additional grouping
- Throws:
IllegalArgumentException
- ifgroupFunction
is null
-
groupByMulti
Apply grouping based on a list of expressions.Adds to any previously specified groupings.
- Parameters:
groupFunction
- function returning a list of expressions by which to group results- Returns:
- a new instance
- Throws:
IllegalArgumentException
- ifgroupFunction
is null
-
having
Add a "having" restriction.Adds to any previously specified "having" restrictions.
- Parameters:
havingFunction
- function returning a test to apply to grouped results- Returns:
- a new instance
- Throws:
IllegalArgumentException
- ifhavingFunction
is null
-
allMatch
Execute this query and return true if the given property is true for every resulting item.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
attribute
- boolean property- Returns:
- true if all results have the given property true
-
allMatch
Execute this query and return true if the predicate returned by the given function is true for every resulting item.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
predicateBuilder
- function mapping this stream's item to a booleanExpression
- Returns:
- true if all results have the computed expression true
-
anyMatch
Execute this query and return true if any results are found for which the given property is true.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
attribute
- boolean property- Returns:
- true if one or more results have the given property true
-
anyMatch
Execute this query and return true if any results are found for which the predicate returned by the given function is true.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
predicateBuilder
- function mapping this stream's item to a booleanExpression
- Returns:
- true if one or more results have the computed expression true
-
noneMatch
Execute this query and return true if no results are found for which the given property is true.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
attribute
- boolean property- Returns:
- true if no results have the given property true
-
noneMatch
Execute this query and return true if no result are found for which the predicate returned by the given function is true.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Parameters:
predicateBuilder
- function mapping this stream's item to a booleanExpression
- Returns:
- true if no results have the computed expression true
-
isEmpty
boolean isEmpty()Execute this query and return true if no results are found.Note: to perform an "exists" operation in a subquery, use
ExprStream.exists()
.Delegates to
TypedQuery.getResultStream()
and can throw any exception thrown by that method.- Returns:
- true if no results are found, false if one or more results are found
- See Also:
-
findAny
SearchValue<X,S> findAny()Find any instance in the stream.- Returns:
- single-valued stream containg any instance in this stream (or
NULL
if this stream is empty)
-
findFirst
SearchValue<X,S> findFirst()Find the first instance in the stream.- Returns:
- single-valued stream containg the first instance in this stream (or
NULL
if this stream is empty)
-
findSingle
SearchValue<X,S> findSingle()Find the only instance in the stream or null.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 asvalue()
ortoOptional()
will generate aNonUniqueResultException
.Using this method is preferable to using
findFirst()
orfindAny()
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);
- Returns:
- a single value, either the only instance in this stream or null if this stream is empty
-
addRoot
Bind an unbound reference to a new query root that will be added to the query.To select the new root in a
SearchStream
, useSearchStream.map()
, providing aFunction
that returnsref
.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.- Type Parameters:
R
- type of the new query root- Parameters:
ref
- unbound referencetype
- type of the new query root- Returns:
- new stream that binds
ref
to a new query root fromtype
- Throws:
IllegalArgumentException
- ifref
is already boundIllegalArgumentException
- iftype
orref
is null
-
map
Map this stream to an associated property.Unlike
join()
, this method allows mapping to arbitrary, non-entity properties.If the property is an entity, then this method works just like an inner
join()
. In particular, the associated entity must exist. For that reason, and also becausejoin()
returns the more specific typeFromStream
,join()
is preferred over this method when the associated property is an entity.- Type Parameters:
Y
- property type- Parameters:
attribute
- associated property- Returns:
- mapped stream
-
map
default <Y> ExprStream<Y,Expression<Y>> map(Class<Y> type, Function<? super S, ? extends Expression<Y>> exprFunction) Map this stream into a stream whose elements are the result of applying the given function.- Type Parameters:
Y
- mapped expression type- Parameters:
type
- new item typeexprFunction
- function mapping this stream'sExpression
to aExpression
- Returns:
- mapped stream
-
map
default <E,C extends Collection<E>> ExprStream<C,Expression<C>> map(PluralAttribute<? super X, C, E> attribute) Map this stream to an associated collection property.- Type Parameters:
E
- collection element typeC
- collection type- Parameters:
attribute
- associated property- Returns:
- mapped stream
-
map
default <K,V, ExprStream<M,M extends Map<K, V>> Expression<M>> map(MapAttribute<? super X, K, V> attribute) Map this stream to an associated map property.- Type Parameters:
K
- map key typeV
- map value typeM
- map type- Parameters:
attribute
- associated property- Returns:
- mapped stream
-
mapToExpr
default <Y> ExprStream<Y,Expression<Y>> mapToExpr(Class<Y> type, Function<? super S, ? extends Expression<Y>> exprFunction) Map this stream into a stream whose elements are the result of applying the given function.- Type Parameters:
Y
- mapped target type- Parameters:
type
- new item typeexprFunction
- function mapping this stream'sSelection
to anExpression
- Returns:
- mapped stream
-
mapToPath
default <Y> PathStream<Y,Path<Y>> mapToPath(Class<Y> type, Function<? super S, ? extends Path<Y>> pathFunction) Map this stream into a stream whose elements are the result of applying the given function. -
mapToFrom
default <Z,Y> FromStream<Y,From<Z, mapToFromY>> (Class<Y> type, Function<? super S, ? extends From<Z, Y>> fromFunction) Map this stream into a stream whose elements are the result of applying the given function. -
mapToRoot
default <Y> RootStream<Y> mapToRoot(Class<Y> type, Function<? super S, ? extends Root<Y>> rootFunction) Map this stream into a stream whose elements are the result of applying the given function. -
mapToRef
Map this stream to a stream whose elements are bound to the supplied root reference.- Type Parameters:
Y
- selection type- Parameters:
ref
- previously bound root reference- Returns:
- mapped stream
-
mapToRef
Map this stream to a stream whose elements are bound to the supplied from reference.- Type Parameters:
Y
- mapped target type- Parameters:
ref
- previously bound from reference- Returns:
- mapped stream
-
mapToRef
Map this stream to a stream whose elements are bound to the supplied path reference.- Type Parameters:
Y
- mapped target type- Parameters:
ref
- previously bound path reference- Returns:
- mapped stream
-
mapToRef
Map this stream to a stream whose elements are bound to the supplied expression reference.- Type Parameters:
Y
- mapped target type- Parameters:
ref
- previously bound expression reference- Returns:
- mapped stream
-
mapToDouble
Map this stream to an associated floating point value.- Parameters:
attribute
- associated numerically-valued property- Returns:
- mapped stream of doubles
-
mapToDouble
default DoubleStream mapToDouble(Function<? super S, ? extends Expression<? extends Number>> doubleExprFunction) Map this stream into a stream of double values that are the result of applying the given function.- Parameters:
doubleExprFunction
- function mapping this stream'sExpression
to a numericalExpression
- Returns:
- mapped stream of doubles
-
mapToLong
Map this stream to an associated long value.- Parameters:
attribute
- associated numerically-valued property- Returns:
- mapped stream of longs
-
mapToLong
default LongStream mapToLong(Function<? super S, ? extends Expression<? extends Number>> longExprFunction) Map this stream into a stream of long values that are the result of applying the given function.- Parameters:
longExprFunction
- function mapping this stream'sExpression
to a numericalExpression
- Returns:
- mapped stream of longs
-
mapToInt
Map this stream to an associated integer value.- Parameters:
attribute
- associated numerically-valued property- Returns:
- mapped stream of integers
-
mapToInt
default IntStream mapToInt(Function<? super S, ? extends Expression<? extends Number>> intExprFunction) Map this stream into a stream of integer values that are the result of applying the given function.- Parameters:
intExprFunction
- function mapping this stream'sExpression
to a numericalExpression
- Returns:
- mapped stream of integers
-
mapToSelection
default <Y> SearchStream<Y,Selection<Y>> mapToSelection(Class<Y> type, Function<? super S, ? extends Selection<Y>> selectionFunction) Map this stream into a stream whose elements are the result of applying the given function.This method provides support for multiple selection using
CriteriaBuilder.array()
,CriteriaBuilder.construct()
, orCriteriaBuilder.tuple()
. For normal single selection, typically you would useSearchStream.map()
instead of this method.- Type Parameters:
Y
- selection type- Parameters:
type
- selection typeselectionFunction
- function to build selection- Returns:
- mapped stream
-
flatMap
Map this stream to a stream where every item is replaced with the contents of the specified collection.- Type Parameters:
E
- collection element type- Parameters:
attribute
- associated collection property- Returns:
- mapped stream
-
flatMap
Map this stream to a stream where every item is replaced with the contents of the specified collection.- Type Parameters:
E
- list element type- Parameters:
attribute
- associated collection property- Returns:
- mapped stream
-
flatMap
Map this stream to a stream where every item is replaced with the contents of the specified collection.- Type Parameters:
E
- set element type- Parameters:
attribute
- associated collection property- Returns:
- mapped stream
-
flatMapKeys
Map this stream to a stream where every item is replaced with the keys of the specified map.- Type Parameters:
K
- map key type- Parameters:
attribute
- associated map property- Returns:
- mapped stream
-
flatMapValues
Map this stream to a stream where every item is replaced with the values of the specified map.- Type Parameters:
V
- map value type- Parameters:
attribute
- associated map property- Returns:
- mapped stream
-
join
Add a singular inner join to this stream.Equivalent to
join(attribute, JoinType.INNER)
.- Type Parameters:
Y
- associated property type- Parameters:
attribute
- associated property- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
join
default <Y> FromStream<Y,From<X, joinY>> (SingularAttribute<? super X, Y> attribute, JoinType joinType) Add a singular join to this stream using the specified join type.Equivalent to
join(attribute, JoinType.INNER, join -> null)
.- Type Parameters:
Y
- associated property type- Parameters:
attribute
- associated propertyjoinType
- type of join- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if either parameter is null
-
join
default <Y> FromStream<Y,From<X, joinY>> (SingularAttribute<? super X, Y> attribute, JoinType joinType, Function<? super Join<X, Y>, ? extends Expression<Boolean>> on) Add a singular join to this stream using the specified join type and ON condition.- Type Parameters:
Y
- associated property type- Parameters:
attribute
- associated propertyjoinType
- type of joinon
- function returning a join ON condition, or returning null for none- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if any parameter is null
-
join
Add a collection inner join to this stream.Equivalent to
join(attribute, JoinType.INNER)
.- Type Parameters:
E
- collection element type- Parameters:
attribute
- associated property- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
join
default <E> FromStream<E,CollectionJoin<X, joinE>> (CollectionAttribute<? super X, E> attribute, JoinType joinType) Add a collection join to this stream using the specified join type.Equivalent to
join(attribute, JoinType.INNER, join -> null)
.- Type Parameters:
E
- collection element type- Parameters:
attribute
- associated propertyjoinType
- type of join- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if either parameter is null
-
join
default <E> FromStream<E,CollectionJoin<X, joinE>> (CollectionAttribute<? super X, E> attribute, JoinType joinType, Function<? super CollectionJoin<X, E>, ? extends Expression<Boolean>> on) Add a collection join to this stream using the specified join type and ON condition.- Type Parameters:
E
- collection element type- Parameters:
attribute
- associated propertyjoinType
- type of joinon
- function returning a join ON condition, or returning null for none- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if any parameter is null
-
join
Add a list inner join to this stream.Equivalent to
join(attribute, JoinType.INNER)
.- Type Parameters:
E
- list element type- Parameters:
attribute
- associated property- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
join
default <E> FromStream<E,ListJoin<X, joinE>> (ListAttribute<? super X, E> attribute, JoinType joinType) Add a list join to this stream using the specified join type.Equivalent to
join(attribute, JoinType.INNER, join -> null)
.- Type Parameters:
E
- list element type- Parameters:
attribute
- associated propertyjoinType
- type of join- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if either parameter is null
-
join
default <E> FromStream<E,ListJoin<X, joinE>> (ListAttribute<? super X, E> attribute, JoinType joinType, Function<? super ListJoin<X, E>, ? extends Expression<Boolean>> on) Add a list join to this stream using the specified join type and ON condition.- Type Parameters:
E
- list element type- Parameters:
attribute
- associated propertyjoinType
- type of joinon
- function returning a join ON condition, or returning null for none- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if any parameter is null
-
join
Add a set inner join to this stream.Equivalent to
join(attribute, JoinType.INNER)
.- Type Parameters:
E
- set element type- Parameters:
attribute
- associated property- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
join
Add a set join to this stream using the specified join type.Equivalent to
join(attribute, JoinType.INNER, join -> null)
.- Type Parameters:
E
- set element type- Parameters:
attribute
- associated propertyjoinType
- type of join- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if either parameter is null
-
join
default <E> FromStream<E,SetJoin<X, joinE>> (SetAttribute<? super X, E> attribute, JoinType joinType, Function<? super SetJoin<X, E>, ? extends Expression<Boolean>> on) Add a set join to this stream using the specified join type and ON condition.- Type Parameters:
E
- set element type- Parameters:
attribute
- associated propertyjoinType
- type of joinon
- function returning a join ON condition, or returning null for none- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if any parameter is null
-
join
Add a map inner join to this stream.Equivalent to
join(attribute, JoinType.INNER)
.- Type Parameters:
K
- map key typeV
- map value type- Parameters:
attribute
- associated property- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
join
default <K,V> FromStream<V,MapJoin<X, joinK, V>> (MapAttribute<? super X, K, V> attribute, JoinType joinType) Add a map join to this stream using the specified join type.Equivalent to
join(attribute, JoinType.INNER, join -> null)
.- Type Parameters:
K
- map key typeV
- map value type- Parameters:
attribute
- associated propertyjoinType
- type of join- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if either parameter is null
-
join
default <K,V> FromStream<V,MapJoin<X, joinK, V>> (MapAttribute<? super X, K, V> attribute, JoinType joinType, Function<? super MapJoin<X, K, V>, ? extends Expression<Boolean>> on) Add a map join to this stream using the specified join type and ON condition.- Type Parameters:
K
- map key typeV
- map value type- Parameters:
attribute
- associated propertyjoinType
- type of joinon
- function returning a join ON condition, or returning null for none- Returns:
- a new stream with specified join
- Throws:
IllegalArgumentException
- if any parameter is null
-
fetch
Add a singular fetch inner join to this stream.Equivalent to
fetch(attribute, JoinType.INNER)
.- Parameters:
attribute
- associated property- Returns:
- a new stream with specified inner fetch join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
fetch
Add a singular fetch join to this stream.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.- Parameters:
attribute
- associated propertyjoinType
- join type- Returns:
- a new stream with specified fetch join
- Throws:
IllegalArgumentException
- if either parameter is null
-
fetch
Add a plural fetch join to this stream.Equivalent to
fetch(attribute, JoinType.INNER)
.- Parameters:
attribute
- associated property- Returns:
- a new stream with specified inner fetch join
- Throws:
IllegalArgumentException
- ifattribute
is null
-
fetch
Add a plural fetch join to this stream.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.- Parameters:
attribute
- associated propertyjoinType
- join type- Returns:
- a new stream with specified fetch join
- Throws:
IllegalArgumentException
- if either parameter is null
-
getQueryType
SearchType<X> getQueryType()Description copied from interface:QueryStream
Get theQueryType
of this instance.- Specified by:
getQueryType
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Returns:
- associated
QueryType
-
bind
Description copied from interface:QueryStream
Bind an unbound reference to the items in this stream.- Specified by:
bind
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
ref
- unbound reference- Returns:
- new stream that binds
ref
-
peek
Description copied from interface:QueryStream
Peek at the items in this stream.This is useful in cases where the selection can be modified, e.g., setting join
ON
conditions usingJoin.on()
.- Specified by:
peek
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
peeker
- peeker into stream- Returns:
- new stream that peeks into this stream
-
bind
<X2,S2 extends Selection<X2>> SearchStream<X,S> bind(Ref<X2, ? super S2> ref, Function<? super S, ? extends S2> refFunction) Description copied from interface:QueryStream
Bind an unbound reference to the result of applying the given function to the items in this stream.- Specified by:
bind
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Type Parameters:
X2
- type of the bound valueS2
- criteria type of the bound value- Parameters:
ref
- unbound referencerefFunction
- function mapping this stream'sSelection
to the reference value- Returns:
- new stream that binds
ref
-
filter
Description copied from interface:QueryStream
Filter results using the specified boolean property.Adds to any previously specified filters.
- Specified by:
filter
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
attribute
- boolean property- Returns:
- new filtered stream
-
filter
Description copied from interface:QueryStream
Filter results using the boolean expression produced by the given function.Adds to any previously specified filters.
- Specified by:
filter
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
predicateBuilder
- function mapping this stream's item to a booleanExpression
- Returns:
- new filtered stream
-
limit
Description copied from interface:QueryStream
Return 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.).
- Specified by:
limit
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
maxSize
- maximum number of elements to return- Returns:
- new truncated stream
-
skip
Description copied from interface:QueryStream
Return 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.).
- Specified by:
skip
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
num
- number of elements to skip- Returns:
- new elided stream
-
withFlushMode
Description copied from interface:QueryStream
Set theFlushModeType
associated with this query.- Specified by:
withFlushMode
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
flushMode
- new flush mode- Returns:
- new stream with the specified flush mode configured
- See Also:
-
withLockMode
Description copied from interface:QueryStream
Set theLockModeType
associated with this query.- Specified by:
withLockMode
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
lockMode
- new lock mode- Returns:
- new stream with the specified lock mode configured
- See Also:
-
withHint
Description copied from interface:QueryStream
Associate a hint with this query.- Specified by:
withHint
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
name
- name of hintvalue
- value of hint- Returns:
- new stream with the specified hint configured
- See Also:
-
withHints
Description copied from interface:QueryStream
Associate hints with this query.- Specified by:
withHints
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
hints
- hints to add- Returns:
- new stream with the specified hints added
- See Also:
-
withParam
Description copied from interface:QueryStream
Bind the value of a query parameter.Replaces any previous binding of the same parameter.
- Specified by:
withParam
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - 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:
-
withParam
Description copied from interface:QueryStream
Bind the value of a query parameter of typeDate
.Replaces any previous binding of the same parameter.
- Specified by:
withParam
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
parameter
- the parameter to setvalue
- parameter valuetemporalType
- temporal type forvalue
- Returns:
- new stream with the specified parameter value set
- See Also:
-
withParam
SearchStream<X,S> withParam(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType) Description copied from interface:QueryStream
Bind the value of a query parameter of typeCalendar
.Replaces any previous binding of the same parameter.
- Specified by:
withParam
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
parameter
- the parameter to setvalue
- parameter valuetemporalType
- temporal type forvalue
- Returns:
- new stream with the specified parameter value set
- See Also:
-
withParams
Description copied from interface:QueryStream
Associate parameter bindings with this query.Replaces any previous bindings of the same parameters.
- Specified by:
withParams
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
params
- bindings to add- Returns:
- new stream with the specified parameter bindings added
- See Also:
-
withLoadGraph
Description copied from interface:QueryStream
Configure a load graph for this query.Equivalent to
withHint
("jakarta.persistence.loadgraph", name)
.- Specified by:
withLoadGraph
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
name
- name of load graph- Returns:
- new stream with the specified load graph configured
-
withFetchGraph
Description copied from interface:QueryStream
Configure a fetch graph for this query.Equivalent to
withHint
("jakarta.persistence.fetchgraph", name)
.- Specified by:
withFetchGraph
in interfaceQueryStream<X,
S extends Selection<X>, AbstractQuery<?>, CriteriaQuery<X>, TypedQuery<X>> - Parameters:
name
- name of fetch graph- Returns:
- new stream with the specified fetch graph configured
-