Class QueryBuilder<T>

java.lang.Object
io.objectbox.query.QueryBuilder<T>
Type Parameters:
T - Entity class for which the Query is built.

public class QueryBuilder<T> extends Object
Builds a Query using conditions which can then be used to return a list of matching Objects.

A simple example:

 userBox.query()
     .equal(User_.firstName, "Joe", StringOrder.CASE_SENSITIVE)
     .order(User_.lastName)
     .build()
     .find()
 

To add a condition use the appropriate method, for example equal(Property, String, StringOrder) or isNull(Property). To order results use order(Property) and its related methods.

Use build() to create a Query object, which is used to actually get the results.

Note: by default Query returns full Objects. To return only values or an aggregate value for a single Property, use Query.property(Property).

See the Queries documentation for details.

  • Field Details

    • DESCENDING

      public static final int DESCENDING
      Reverts the order from ascending (default) to descending.
      See Also:
    • CASE_SENSITIVE

      public static final int CASE_SENSITIVE
      Makes upper case letters (e.g. "Z") be sorted before lower case letters (e.g. "a"). If not specified, the default is case insensitive for ASCII characters.
      See Also:
    • NULLS_LAST

      public static final int NULLS_LAST
      null values will be put last. If not specified, by default null values will be put first.
      See Also:
    • NULLS_ZERO

      public static final int NULLS_ZERO
      null values should be treated equal to zero (scalars only).
      See Also:
    • UNSIGNED

      public static final int UNSIGNED
      For scalars only: changes the comparison to unsigned (default is signed).
      See Also:
  • Constructor Details

    • QueryBuilder

      @Internal public QueryBuilder(Box<T> box, long storeHandle, String entityName)
  • Method Details