where

public B where(Array<Filter> predicate)

Sets the predicates for the io.spine.client.Query.

If there are no io.spine.client.Filters (i.e. the passed array is empty), all the records will be retrieved regardless of the column values.

The multiple parameters passed into this method are considered to be joined in a conjunction (ALL operator), i.e. a record matches this query only if it matches all of these parameters.

Return

self for method chaining

Parameters

predicate

the io.spine.client.Filters to filter the query results

See also

for a convenient way to create io.spine.client.Filter instances


public B where(Array<CompositeFilter> predicate)

Sets the predicates for the io.spine.client.Query.

If there are no io.spine.client.Filters (i.e. the passed array is empty), all the records will be retrieved regardless the column values.

The input values represent groups of simple filters joined with a composite operator.

The input filter groups are effectively joined between each other by ALL operator, i.e. a record matches this query if it matches all the composite filters.

Example of usage:


    factory.select(Customer.class)
           // Possibly other parameters
           .where(all(ge("companySize", 50), le("companySize", 1000)),
                  either(gt("establishedTime", twoYearsAgo), eq("country", "Germany")))
           .build();

In the example above, the Customer records match the built query if they represent companies that have their company size between 50 and 1000 employees and either have been established less than two years ago, or originate from Germany.

Note that the filters which belong to different all(...) groups may be represented as a single all(...) group. For example, two following queries would be identical:


    // Option 1
    factory.select(Customer.class)
           .where(all(
                      eq("country", "Germany")),
                  all(
                      ge("companySize", 50),
                      le("companySize", 100)))
           .build();

    // Option 2 (identical)
    factory.select(Customer.class)
           .where(all(
                      eq("country", "Germany"),
                      ge("companySize", 50),
                      le("companySize", 100)))
           .build();

The Option 1 is recommended in this case, since the filters are grouped logically, though both builders produce effectively the same io.spine.client.Query instances. Note, that those instances may not be equal in terms of equals method.

Return

self for method chaining

Parameters

predicate

a number of io.spine.client.CompositeFilter instances forming the query predicate

See also

for a convenient way to create io.spine.client.CompositeFilter instances