QueryBuilder

public final class QueryBuilder extends TargetBuilder<T, B>

A builder for the Query instances.

None of the parameters set by the builder methods are required. Call build to retrieve the resulting Query instance.

Usage example:


ActorRequestFactory factory = ... ;
Query query = factory.query()
         .select(Customer.class)
         .byId(westCoastCustomerIds())
         .withMask("name", "address", "email")
         .where(eq("type", "permanent"),
                eq("discountPercent", 10),
                eq("companySize", Company.Size.SMALL))
         .orderBy("name", ASCENDING)
         .limit(20)
         .build();

Arguments for the where method can be composed using the Filters utility class.

See also

Functions

Link copied to clipboard
public Query build()
Generates a new Query instance with current builder configuration.
Link copied to clipboard
public QueryBuilder limit(int count)
Limits the number of results returned by the query.
Link copied to clipboard
public QueryBuilder orderBy(String column, Direction direction)
Sets the sorting order by the target column and order direction.

Inherited functions

Link copied to clipboard
public B byId(Array<Message> ids)
public B byId(Array<Integer> ids)
public B byId(Array<Long> ids)
public B byId(Array<String> ids)
Sets the ID predicate to the io.spine.client.
public B byId(Iterable<? extends Object> ids)
Sets the ID predicate to the targets of the request.
Link copied to clipboard
public String toString()
Link copied to clipboard
public B where(Array<CompositeFilter> predicate)
public B where(Array<Filter> predicate)
Sets the predicates for the io.spine.client.
Link copied to clipboard
public B withMask(Iterable<String> fieldNames)
public B withMask(Array<String> fieldNames)
Sets the entity fields to retrieve.