X - stream item typeS - criteria type for stream itempublic interface SearchStream<X,S extends Selection<X>> extends QueryStream<X,S,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>
Stream-like API.QueryStream.Builder| Modifier and Type | Method and Description |
|---|---|
<R> SearchStream<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.
|
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 |
allMatch(SingularAttribute<? super X,Boolean> attribute)
Execute this query and return true if the given property is true for every resulting item.
|
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.
|
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.
|
SearchStream<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.
|
SearchStream<X,S> |
distinct()
Suppress duplicates.
|
SearchStream<X,S> |
fetch(PluralAttribute<? super X,?,?> attribute)
Add a plural fetch join to this stream.
|
SearchStream<X,S> |
fetch(PluralAttribute<? super X,?,?> attribute,
JoinType joinType)
Add a plural fetch join to this stream.
|
SearchStream<X,S> |
fetch(SingularAttribute<? super X,?> attribute)
Add a singular fetch inner join to this stream.
|
SearchStream<X,S> |
fetch(SingularAttribute<? super X,?> attribute,
JoinType joinType)
Add a singular fetch join to this stream.
|
SearchStream<X,S> |
filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Filter results using the boolean expression produced by the given function.
|
SearchStream<X,S> |
filter(SingularAttribute<? super X,Boolean> attribute)
Filter results using the specified boolean property.
|
SearchValue<X,S> |
findAny()
Find any instance in the stream.
|
SearchValue<X,S> |
findFirst()
Find the first instance in the stream.
|
SearchValue<X,S> |
findSingle()
Find the only instance in the stream.
|
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.
|
SearchType<X> |
getQueryType()
Get the
QueryType of this instance. |
default List<X> |
getResultList()
Build and evaluate a JPA query based on this instance and return the result list.
|
default Stream<X> |
getResultStream()
Build and evaluate a JPA query based on this instance and return the result stream.
|
SearchStream<X,S> |
groupBy(Function<? super S,? extends Expression<?>> groupFunction)
Apply grouping based on a single expression.
|
SearchStream<X,S> |
groupBy(Ref<?,? extends Expression<?>> ref)
Apply grouping based on an expression reference.
|
SearchStream<X,S> |
groupBy(SingularAttribute<? super X,?> attribute)
Apply grouping based on the specified property.
|
SearchStream<X,S> |
groupByMulti(Function<? super S,? extends List<Expression<?>>> groupFunction)
Apply grouping based on a list of expressions.
|
SearchStream<X,S> |
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.
|
SearchStream<X,S> |
limit(int maxSize)
Return this stream truncated to the specified maximum length.
|
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 <K,V,M extends Map<K,V>> |
map(MapAttribute<? super X,K,V> attribute)
Map this stream to an associated map property.
|
default <E,C extends Collection<E>> |
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 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 DoubleStream |
mapToDouble(SingularAttribute<? super X,? extends Number> attribute)
Map this stream to an associated floating point value.
|
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>> |
mapToFrom(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.
|
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 IntStream |
mapToInt(SingularAttribute<? super X,? extends Number> attribute)
Map this stream to an associated integer 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 LongStream |
mapToLong(SingularAttribute<? super X,? extends Number> attribute)
Map this stream to an associated long value.
|
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.
|
default <Y> ExprStream<Y,Expression<Y>> |
mapToRef(Class<Y> type,
ExprRef<Y> ref)
Map this stream to a stream whose elements are bound to the supplied expression reference.
|
default <Y> FromStream<Y,From<?,Y>> |
mapToRef(Class<Y> type,
FromRef<Y> ref)
Map this stream to a stream whose elements are bound to the supplied from reference.
|
default <Y> PathStream<Y,Path<Y>> |
mapToRef(Class<Y> type,
PathRef<Y> ref)
Map this stream to a stream whose elements are bound to the supplied path reference.
|
default <Y> RootStream<Y> |
mapToRef(Class<Y> type,
RootRef<Y> ref)
Map this stream to a stream whose elements are bound to the supplied root reference.
|
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.
|
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(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.
|
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.
|
SearchStream<X,S> |
orderBy(Function<? super S,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function. |
SearchStream<X,S> |
orderBy(Order... orders)
Order results using the specified
Orders. |
SearchStream<X,S> |
orderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference.
|
SearchStream<X,S> |
orderBy(SingularAttribute<? super X,?> attribute,
boolean asc)
Order results using the specified property.
|
SearchStream<X,S> |
orderBy(SingularAttribute<? super X,?> attribute1,
boolean asc1,
SingularAttribute<? super X,?> attribute2,
boolean asc2)
Order results using the specified properties.
|
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.
|
SearchStream<X,S> |
orderByMulti(Function<? super S,? extends List<? extends Order>> orderListFunction)
|
SearchStream<X,S> |
peek(Consumer<? super S> peeker)
Peek at the items in this stream.
|
SearchStream<X,S> |
skip(int num)
Return this stream with the specified number of initial elements skipped.
|
SearchStream<X,S> |
thenOrderBy(Function<? super S,? extends Expression<?>> orderExprFunction,
boolean asc)
Order results using the
Expression produced by the given Function after existing sort. |
SearchStream<X,S> |
thenOrderBy(Order... orders)
Order results using the specified
Orders after existing sort. |
SearchStream<X,S> |
thenOrderBy(Ref<?,? extends Expression<?>> ref,
boolean asc)
Order results using the specified expression reference after existing sort.
|
SearchStream<X,S> |
thenOrderBy(SingularAttribute<? super X,?> attribute,
boolean asc)
Order results using the specified property after existing sort.
|
SearchStream<X,S> |
withFetchGraph(String name)
Configure a fetch graph for this query.
|
SearchStream<X,S> |
withFlushMode(FlushModeType flushMode)
Set the
FlushModeType associated with this query. |
SearchStream<X,S> |
withHint(String name,
Object value)
Associate a hint with this query.
|
SearchStream<X,S> |
withHints(Map<String,Object> hints)
Associate hints with this query.
|
SearchStream<X,S> |
withLoadGraph(String name)
Configure a load graph for this query.
|
SearchStream<X,S> |
withLockMode(LockModeType lockMode)
Set the
LockModeType associated with this query. |
SearchStream<X,S> |
withParam(Parameter<Calendar> parameter,
Calendar value,
TemporalType temporalType)
Bind the value of a query parameter of type
Calendar. |
SearchStream<X,S> |
withParam(Parameter<Date> parameter,
Date value,
TemporalType temporalType)
Bind the value of a query parameter of type
Date. |
<T> SearchStream<X,S> |
withParam(Parameter<T> parameter,
T value)
Bind the value of a query parameter.
|
SearchStream<X,S> |
withParams(Iterable<? extends ParamBinding<?>> params)
Associate parameter bindings with this query.
|
getEntityManager, getFirstResult, getFlushMode, getHints, getLockMode, getMaxResults, getParams, newBuilder, toCriteriaQuery, toQueryconfiguredefault List<X> getResultList()
Delegates to TypedQuery.getResultList() and can throw any exception thrown by that method.
TypedQuery.getResultList()default Stream<X> getResultStream()
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
TypedQuery.getResultStream()SearchStream<X,S> distinct()
SearchStream<X,S> orderBy(SingularAttribute<? super X,?> attribute, boolean asc)
Replaces any existing sort ordering.
attribute - associated propertyasc - true for ascending, false for descendingIllegalArgumentException - if attribute is nullSearchStream<X,S> orderBy(SingularAttribute<? super X,?> attribute1, boolean asc1, SingularAttribute<? super X,?> attribute2, boolean asc2)
Replaces any existing sort ordering.
attribute1 - associated propertyasc1 - true for attribute1 ascending, false for attribute1 descendingattribute2 - associated propertyasc2 - true for attribute2 ascending, false for attribute2 descendingIllegalArgumentException - if attribute1 or attribute2 is nullSearchStream<X,S> orderBy(SingularAttribute<? super X,?> attribute1, boolean asc1, SingularAttribute<? super X,?> attribute2, boolean asc2, SingularAttribute<? super X,?> attribute3, boolean asc3)
Replaces any existing sort ordering.
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 descendingIllegalArgumentException - if attribute1, attribute2, or attribute3 is nullSearchStream<X,S> orderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
Replaces any existing sort ordering.
ref - previously bound expression referenceasc - true for ascending, false for descendingIllegalArgumentException - if ref is nullSearchStream<X,S> orderBy(Order... orders)
Orders.
Replaces any existing sort ordering.
orders - ordering(s), with higher precedence orderings firstIllegalArgumentException - if orders is nullSearchStream<X,S> orderBy(Function<? super S,? extends Expression<?>> orderExprFunction, boolean asc)
Expression produced by the given Function.
Replaces any existing sort ordering.
orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingIllegalArgumentException - if orderExprFunction is nullSearchStream<X,S> orderByMulti(Function<? super S,? extends List<? extends Order>> orderListFunction)
Order list produced by the given Function.
Replaces any existing sort ordering.
orderListFunction - Function that produces the sort ordering given an item expressionIllegalArgumentException - if orderListFunction is nullSearchStream<X,S> thenOrderBy(SingularAttribute<? super X,?> attribute, boolean asc)
Adds to any existing sort ordering.
attribute - associated propertyasc - true for ascending, false for descendingIllegalArgumentException - if attribute is nullSearchStream<X,S> thenOrderBy(Ref<?,? extends Expression<?>> ref, boolean asc)
Adds to any existing sort ordering.
ref - previously bound expression referenceasc - true for ascending, false for descendingIllegalArgumentException - if ref is nullSearchStream<X,S> thenOrderBy(Order... orders)
Orders after existing sort.
Adds to any existing sort ordering.
orders - ordering(s), with higher precedence orderings firstIllegalArgumentException - if orders is nullSearchStream<X,S> thenOrderBy(Function<? super S,? extends Expression<?>> orderExprFunction, boolean asc)
Expression produced by the given Function after existing sort.
Adds to any existing sort ordering.
orderExprFunction - Function that produces an Expression to order on given an item expressionasc - true for ascending, false for descendingIllegalArgumentException - if orderExprFunction is nullSearchStream<X,S> groupBy(Ref<?,? extends Expression<?>> ref)
Adds to any previously specified groupings.
ref - previously bound expression referenceIllegalArgumentException - if ref is nullSearchStream<X,S> groupBy(SingularAttribute<? super X,?> attribute)
Adds to any previously specified groupings.
attribute - associated propertyIllegalArgumentException - if attribute is nullSearchStream<X,S> groupBy(Function<? super S,? extends Expression<?>> groupFunction)
Adds to any previously specified groupings.
groupFunction - function returning an expression by which to group resultsIllegalArgumentException - if groupFunction is nullSearchStream<X,S> groupByMulti(Function<? super S,? extends List<Expression<?>>> groupFunction)
Adds to any previously specified groupings.
groupFunction - function returning a list of expressions by which to group resultsIllegalArgumentException - if groupFunction is nullSearchStream<X,S> having(Function<? super S,? extends Expression<Boolean>> havingFunction)
Adds to any previously specified "having" restrictions.
havingFunction - function returning a test to apply to grouped resultsIllegalArgumentException - if havingFunction is nullboolean allMatch(SingularAttribute<? super X,Boolean> attribute)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
attribute - boolean propertyboolean allMatch(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
predicateBuilder - function mapping this stream's item to a boolean Expressionboolean anyMatch(SingularAttribute<? super X,Boolean> attribute)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
attribute - boolean propertyboolean anyMatch(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
predicateBuilder - function mapping this stream's item to a boolean Expressionboolean noneMatch(SingularAttribute<? super X,Boolean> attribute)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
attribute - boolean propertyboolean noneMatch(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
Delegates to TypedQuery.getResultStream() and can throw any exception thrown by that method.
predicateBuilder - function mapping this stream's item to a boolean Expressionboolean isEmpty()
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.
ExprStream.exists()SearchValue<X,S> findAny()
NULL if this stream is empty)SearchValue<X,S> findFirst()
NULL if this stream is empty)SearchValue<X,S> findSingle()
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 findFirst() or 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);
NULL if this stream is empty)<R> SearchStream<X,S> addRoot(Ref<R,? super Root<R>> ref, Class<R> type)
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.
R - type of the new query rootref - unbound referencetype - type of the new query rootref to a new query root from typeIllegalArgumentException - if ref is already boundIllegalArgumentException - if type or ref is nulldefault <Y> PathStream<Y,Path<Y>> map(SingularAttribute<? super X,Y> attribute)
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 because join()
returns the more specific type FromStream, join() is preferred over this
method when the associated property is an entity.
Y - property typeattribute - associated propertydefault <Y> ExprStream<Y,Expression<Y>> map(Class<Y> type, Function<? super S,? extends Expression<Y>> exprFunction)
Y - mapped expression typetype - new item typeexprFunction - function mapping this stream's Expression to a Expressiondefault <E,C extends Collection<E>> ExprStream<C,Expression<C>> map(PluralAttribute<? super X,C,E> attribute)
E - collection element typeC - collection typeattribute - associated propertydefault <K,V,M extends Map<K,V>> ExprStream<M,Expression<M>> map(MapAttribute<? super X,K,V> attribute)
K - map key typeV - map value typeM - map typeattribute - associated propertydefault <Y> ExprStream<Y,Expression<Y>> mapToExpr(Class<Y> type, Function<? super S,? extends Expression<Y>> exprFunction)
Y - mapped target typetype - new item typeexprFunction - function mapping this stream's Selection to an Expressiondefault <Y> PathStream<Y,Path<Y>> mapToPath(Class<Y> type, Function<? super S,? extends Path<Y>> pathFunction)
default <Z,Y> FromStream<Y,From<Z,Y>> mapToFrom(Class<Y> type, Function<? super S,? extends From<Z,Y>> fromFunction)
default <Y> RootStream<Y> mapToRoot(Class<Y> type, Function<? super S,? extends Root<Y>> rootFunction)
default <Y> RootStream<Y> mapToRef(Class<Y> type, RootRef<Y> ref)
Y - selection typeref - previously bound root referencedefault <Y> FromStream<Y,From<?,Y>> mapToRef(Class<Y> type, FromRef<Y> ref)
Y - mapped target typeref - previously bound from referencedefault <Y> PathStream<Y,Path<Y>> mapToRef(Class<Y> type, PathRef<Y> ref)
Y - mapped target typeref - previously bound path referencedefault <Y> ExprStream<Y,Expression<Y>> mapToRef(Class<Y> type, ExprRef<Y> ref)
Y - mapped target typeref - previously bound expression referencedefault DoubleStream mapToDouble(SingularAttribute<? super X,? extends Number> attribute)
attribute - associated numerically-valued propertydefault DoubleStream mapToDouble(Function<? super S,? extends Expression<? extends Number>> doubleExprFunction)
doubleExprFunction - function mapping this stream's Expression to a numerical Expressiondefault LongStream mapToLong(SingularAttribute<? super X,? extends Number> attribute)
attribute - associated numerically-valued propertydefault LongStream mapToLong(Function<? super S,? extends Expression<? extends Number>> longExprFunction)
longExprFunction - function mapping this stream's Expression to a numerical Expressiondefault IntStream mapToInt(SingularAttribute<? super X,? extends Number> attribute)
attribute - associated numerically-valued propertydefault IntStream mapToInt(Function<? super S,? extends Expression<? extends Number>> intExprFunction)
intExprFunction - function mapping this stream's Expression to a numerical Expressiondefault <Y> SearchStream<Y,Selection<Y>> mapToSelection(Class<Y> type, Function<? super S,? extends Selection<Y>> selectionFunction)
This method provides support for multiple selection using
CriteriaBuilder.array(),
CriteriaBuilder.construct(), or
CriteriaBuilder.tuple().
For normal single selection, typically you would use SearchStream.map() instead of this method.
Y - selection typetype - selection typeselectionFunction - function to build selectiondefault <E> FromStream<E,CollectionJoin<X,E>> flatMap(CollectionAttribute<? super X,E> attribute)
E - collection element typeattribute - associated collection propertydefault <E> FromStream<E,ListJoin<X,E>> flatMap(ListAttribute<? super X,E> attribute)
E - list element typeattribute - associated collection propertydefault <E> FromStream<E,SetJoin<X,E>> flatMap(SetAttribute<? super X,E> attribute)
E - set element typeattribute - associated collection propertydefault <K> PathStream<K,Path<K>> flatMapKeys(MapAttribute<? super X,K,?> attribute)
K - map key typeattribute - associated map propertydefault <V> PathStream<V,Path<V>> flatMapValues(MapAttribute<? super X,?,V> attribute)
V - map value typeattribute - associated map propertydefault <Y> FromStream<Y,From<X,Y>> join(SingularAttribute<? super X,Y> attribute)
Equivalent to join(attribute, JoinType.INNER).
Y - associated property typeattribute - associated propertyIllegalArgumentException - if attribute is nulldefault <Y> FromStream<Y,From<X,Y>> join(SingularAttribute<? super X,Y> attribute, JoinType joinType)
Equivalent to join(attribute, JoinType.INNER, join -> null).
Y - associated property typeattribute - associated propertyjoinType - type of joinIllegalArgumentException - if either parameter is nulldefault <Y> FromStream<Y,From<X,Y>> join(SingularAttribute<? super X,Y> attribute, JoinType joinType, Function<? super Join<X,Y>,? extends Expression<Boolean>> on)
Y - associated property typeattribute - associated propertyjoinType - type of joinon - function returning a join ON condition, or returning null for noneIllegalArgumentException - if any parameter is nulldefault <E> FromStream<E,CollectionJoin<X,E>> join(CollectionAttribute<? super X,E> attribute)
Equivalent to join(attribute, JoinType.INNER).
E - collection element typeattribute - associated propertyIllegalArgumentException - if attribute is nulldefault <E> FromStream<E,CollectionJoin<X,E>> join(CollectionAttribute<? super X,E> attribute, JoinType joinType)
Equivalent to join(attribute, JoinType.INNER, join -> null).
E - collection element typeattribute - associated propertyjoinType - type of joinIllegalArgumentException - if either parameter is nulldefault <E> FromStream<E,CollectionJoin<X,E>> join(CollectionAttribute<? super X,E> attribute, JoinType joinType, Function<? super CollectionJoin<X,E>,? extends Expression<Boolean>> on)
E - collection element typeattribute - associated propertyjoinType - type of joinon - function returning a join ON condition, or returning null for noneIllegalArgumentException - if any parameter is nulldefault <E> FromStream<E,ListJoin<X,E>> join(ListAttribute<? super X,E> attribute)
Equivalent to join(attribute, JoinType.INNER).
E - list element typeattribute - associated propertyIllegalArgumentException - if attribute is nulldefault <E> FromStream<E,ListJoin<X,E>> join(ListAttribute<? super X,E> attribute, JoinType joinType)
Equivalent to join(attribute, JoinType.INNER, join -> null).
E - list element typeattribute - associated propertyjoinType - type of joinIllegalArgumentException - if either parameter is nulldefault <E> FromStream<E,ListJoin<X,E>> join(ListAttribute<? super X,E> attribute, JoinType joinType, Function<? super ListJoin<X,E>,? extends Expression<Boolean>> on)
E - list element typeattribute - associated propertyjoinType - type of joinon - function returning a join ON condition, or returning null for noneIllegalArgumentException - if any parameter is nulldefault <E> FromStream<E,SetJoin<X,E>> join(SetAttribute<? super X,E> attribute)
Equivalent to join(attribute, JoinType.INNER).
E - set element typeattribute - associated propertyIllegalArgumentException - if attribute is nulldefault <E> FromStream<E,SetJoin<X,E>> join(SetAttribute<? super X,E> attribute, JoinType joinType)
Equivalent to join(attribute, JoinType.INNER, join -> null).
E - set element typeattribute - associated propertyjoinType - type of joinIllegalArgumentException - if either parameter is nulldefault <E> FromStream<E,SetJoin<X,E>> join(SetAttribute<? super X,E> attribute, JoinType joinType, Function<? super SetJoin<X,E>,? extends Expression<Boolean>> on)
E - set element typeattribute - associated propertyjoinType - type of joinon - function returning a join ON condition, or returning null for noneIllegalArgumentException - if any parameter is nulldefault <K,V> FromStream<V,MapJoin<X,K,V>> join(MapAttribute<? super X,K,V> attribute)
Equivalent to join(attribute, JoinType.INNER).
K - map key typeV - map value typeattribute - associated propertyIllegalArgumentException - if attribute is nulldefault <K,V> FromStream<V,MapJoin<X,K,V>> join(MapAttribute<? super X,K,V> attribute, JoinType joinType)
Equivalent to join(attribute, JoinType.INNER, join -> null).
K - map key typeV - map value typeattribute - associated propertyjoinType - type of joinIllegalArgumentException - if either parameter is nulldefault <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)
K - map key typeV - map value typeattribute - associated propertyjoinType - type of joinon - function returning a join ON condition, or returning null for noneIllegalArgumentException - if any parameter is nullSearchStream<X,S> fetch(SingularAttribute<? super X,?> attribute)
Equivalent to fetch(attribute, JoinType.INNER).
attribute - associated propertyIllegalArgumentException - if attribute is nullSearchStream<X,S> fetch(SingularAttribute<? super X,?> attribute, JoinType joinType)
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.
attribute - associated propertyjoinType - join typeIllegalArgumentException - if either parameter is nullSearchStream<X,S> fetch(PluralAttribute<? super X,?,?> attribute)
Equivalent to fetch(attribute, JoinType.INNER).
attribute - associated propertyIllegalArgumentException - if attribute is nullSearchStream<X,S> fetch(PluralAttribute<? super X,?,?> attribute, JoinType joinType)
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.
attribute - associated propertyjoinType - join typeIllegalArgumentException - if either parameter is nullSearchType<X> getQueryType()
QueryStreamQueryType of this instance.getQueryType in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>QueryTypeSearchStream<X,S> bind(Ref<X,? super S> ref)
QueryStreambind in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>ref - unbound referencerefSearchStream<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 QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>peeker - peeker into stream<X2,S2 extends Selection<X2>> SearchStream<X,S> bind(Ref<X2,? super S2> ref, Function<? super S,? extends S2> refFunction)
QueryStreambind in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>X2 - type of the bound valueS2 - criteria type of the bound valueref - unbound referencerefFunction - function mapping this stream's Selection to the reference valuerefSearchStream<X,S> filter(SingularAttribute<? super X,Boolean> attribute)
QueryStreamAdds to any previously specified filters.
filter in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>attribute - boolean propertySearchStream<X,S> filter(Function<? super S,? extends Expression<Boolean>> predicateBuilder)
QueryStreamAdds to any previously specified filters.
filter in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>predicateBuilder - function mapping this stream's item to a boolean ExpressionSearchStream<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 QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>maxSize - maximum number of elements to returnSearchStream<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 QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>num - number of elements to skipSearchStream<X,S> withFlushMode(FlushModeType flushMode)
QueryStreamFlushModeType associated with this query.withFlushMode in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>flushMode - new flush modeQuery.setFlushMode(javax.persistence.FlushModeType)SearchStream<X,S> withLockMode(LockModeType lockMode)
QueryStreamLockModeType associated with this query.withLockMode in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>lockMode - new lock modeQuery.setLockMode(javax.persistence.LockModeType)SearchStream<X,S> withHint(String name, Object value)
QueryStreamwithHint in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>name - name of hintvalue - value of hintQuery.setHint(java.lang.String, java.lang.Object)SearchStream<X,S> withHints(Map<String,Object> hints)
QueryStreamwithHints in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>hints - hints to addQuery.setHint(java.lang.String, java.lang.Object)<T> SearchStream<X,S> withParam(Parameter<T> parameter, T value)
QueryStreamReplaces any previous binding of the same parameter.
withParam in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>T - parameter value typeparameter - the parameter to setvalue - parameter valueQuery.setParameter(javax.persistence.Parameter, Object)SearchStream<X,S> withParam(Parameter<Date> parameter, Date value, TemporalType temporalType)
QueryStreamDate.
Replaces any previous binding of the same parameter.
withParam in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Date, TemporalType)SearchStream<X,S> withParam(Parameter<Calendar> parameter, Calendar value, TemporalType temporalType)
QueryStreamCalendar.
Replaces any previous binding of the same parameter.
withParam in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>parameter - the parameter to setvalue - parameter valuetemporalType - temporal type for valueQuery.setParameter(javax.persistence.Parameter, Calendar, TemporalType)SearchStream<X,S> withParams(Iterable<? extends ParamBinding<?>> params)
QueryStreamReplaces any previous bindings of the same parameters.
withParams in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>params - bindings to addQuery.setParameter(javax.persistence.Parameter, Object)SearchStream<X,S> withLoadGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.loadgraph", name).
withLoadGraph in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>name - name of load graphSearchStream<X,S> withFetchGraph(String name)
QueryStream
Equivalent to withHint("javax.persistence.fetchgraph", name).
withFetchGraph in interface QueryStream<X,S extends Selection<X>,AbstractQuery<?>,CriteriaQuery<X>,TypedQuery<X>>name - name of fetch graphCopyright © 2023. All rights reserved.