S
- the type of the queried entity statespublic final class QueryRequest<S extends io.spine.base.EntityState> extends FilteringRequest<S,io.spine.client.Query,QueryBuilder,QueryRequest<S>>
None of the parameters set by the builder methods are required. Call QueryRequest.run()
to
retrieve the results of the query.
Usage example:
ImmutableList<Customer> customers = client.onBehalfOf(currentUser)
.select(Customer.class)
.byId(westCoastCustomerIds())
.withMask("name", "address", "email")
.where(eq(Customer.Column.type(), "permanent"),
eq(Customer.Column.discountPercent(), 10),
eq(Customer.Column.companySize(), Company.Size.SMALL))
.orderBy(Customer.Column.name(), ASCENDING)
.limit(20)
.run();
Filtering by field values (via QueryRequest.where(QueryFilter...)
and
QueryRequest.where(CompositeQueryFilter...)
methods) can be composed using the Filters
utility class.
Filters
Modifier and Type | Method and Description |
---|---|
QueryRequest<S> |
limit(int count)
Limits the number of results returned by the query.
|
QueryRequest<S> |
orderBy(io.spine.base.EntityColumn column,
io.spine.client.OrderBy.Direction direction)
Sets the sorting order by the target column and order direction.
|
QueryRequest<S> |
orderBy(java.lang.String column,
io.spine.client.OrderBy.Direction direction)
Deprecated.
Please use the alternative
which relies on strongly-typed columns instead.
|
com.google.common.collect.ImmutableList<S> |
run()
Obtains results of the query.
|
QueryRequest<S> |
where(CompositeQueryFilter... filter)
Configures the request to return results matching all the passed filters.
|
QueryRequest<S> |
where(QueryFilter... filter)
Configures the request to return results matching all the passed filters.
|
byId, byId, byId, byId, byId, where, where, withMask, withMask
client, command, onServerError, onStreamingError, select, subscribeTo, subscribeToEvent, user
public QueryRequest<S> where(QueryFilter... filter)
public QueryRequest<S> where(CompositeQueryFilter... filter)
@Deprecated public QueryRequest<S> orderBy(java.lang.String column, io.spine.client.OrderBy.Direction direction)
column
- the column to sort bydirection
- sorting directionpublic QueryRequest<S> orderBy(io.spine.base.EntityColumn column, io.spine.client.OrderBy.Direction direction)
column
- the column to sort bydirection
- sorting directionpublic QueryRequest<S> limit(int count)
count
- the number of results to be returnedpublic com.google.common.collect.ImmutableList<S> run()