T - Entity typepublic interface Query<T> extends Iterable<T>
QueryBuilder, which decides the "where" clause in the query.
Additional limitations, such as paging, ordering, and variables, can be set on a Query before it is executed by calling one of find(), iterator(), or count().
DDD tip: typically Queries are created in the Domain Model and passed to the UI, which sets the order and paging before executing it.
| Modifier and Type | Method and Description |
|---|---|
long |
count()
Count how many results would be returned by this Query.
|
T |
find()
Get the first Entity that matches the criteria.
|
Query<T> |
firstResult(int firstResult)
Set the index of the first result.
|
<V> V |
getVariable(String name)
Get the value of a named variable.
|
Query<T> |
maxResults(int maxResults)
Set how many results should be returned.
|
Query<T> |
orderBy(OrderBy... segments)
Set the ordering rules.
|
Query<T> |
orderBy(Property<?> property)
Append an ascending ordering rule to the existing segments.
|
Query<T> |
orderBy(Property<?> property,
OrderBy.Order order)
Append an ordering rule to the existing segments.
|
Class<T> |
resultType()
Get the result type of this Query
|
Query<T> |
setVariable(String name,
Object value)
Set the value of a named variable.
|
Stream<T> |
stream() |
forEach, iterator, spliteratorQuery<T> orderBy(OrderBy... segments)
segments - the segments to order byQuery<T> orderBy(Property<?> property, OrderBy.Order order)
property - the property to order byorder - the order to applyQuery<T> orderBy(Property<?> property)
property - the property to order byQuery<T> firstResult(int firstResult)
firstResult - which index to use as the first oneQuery<T> maxResults(int maxResults)
maxResults - that shouldbe returnedT find() throws QueryExecutionException
QueryExecutionException - if the query failsQuery<T> setVariable(String name, Object value)
name - of the variablevalue - of the variable<V> V getVariable(String name)
V - Variable typename - of the variablelong count()
throws QueryExecutionException
QueryExecutionException - if the query fails