Class QueryImpl<T>

java.lang.Object
com.googlecode.objectify.impl.SimpleQueryImpl<T>
com.googlecode.objectify.impl.QueryImpl<T>
All Implemented Interfaces:
Query<T>, QueryExecute<T>, QueryResultIterable<T>, SimpleQuery<T>, Cloneable, Iterable<T>

public class QueryImpl<T> extends SimpleQueryImpl<T> implements Query<T>, Cloneable
Implementation of Query.
Author:
Jeff Schnitzer invalid input: '<'[email protected]>
  • Method Details

    • filter

      public QueryImpl<T> filter(String condition, Object value)
      Description copied from interface: Query

      Create a filter based on the specified condition and value, using the same syntax as the GAE/Python query class. Examples:

      • filter("age >=", age)
      • filter("age =", age)
      • filter("age", age) (if no operator, = is assumed)
      • filter("age !=", age)
      • filter("age IN", Arrays.asList(25, 35, 45)
      • filter("age !IN", Arrays.asList(25, 35, 45)

      The space between the property name and the operator is required. Filtering a condition of "age>=" will perform an equality test on an entity property exactly named "age>=". You can't create properties like this with Objectify, but you can with the Low-Level API.

      Multiple calls to filter() will produce an AND (intersection) query.

      == is an alias of =, <> is an alias of !=.

      See the Google documentation for indexes for an explanation of what you can and cannot filter for.

      You can not filter on @Id or @Parent properties. Use filterKey() or ancestor() instead.

      Specified by:
      filter in interface Query<T>
    • filter

      public QueryImpl<T> filter(com.google.cloud.datastore.StructuredQuery.Filter filter)
      Description copied from interface: Query

      Create a filter based on the raw low-level Filter. This is a very low-level operation; the values in the Filter are not translated in any way. For example, this only understands native datastore Key objects and not Objectify Key<?> objects.

      See the Google documentation for indexes for an explanation of what you can and cannot filter for.

      You can not filter on @Id or @Parent properties. Use filterKey() or ancestor() instead.

      Specified by:
      filter in interface Query<T>
    • filter

      public QueryImpl<T> filter(Filter filter)
      Description copied from interface: Query

      Create an arbitrarily complex filter. This method is preferred to the low-level Filter method because it has better ergonomics and automatically handles objects like Objectify Key<?> and Ref<?>.

      Construct Filter objects using static methods on the Filter class.

      Note that like the other filter methods, you can not filter on @Id or @Parent properties. You can filter by __key__ however.

      Specified by:
      filter in interface Query<T>
    • order

      public QueryImpl<T> order(String condition)
      Description copied from interface: Query

      Sorts based on a property. Examples:

      • order("age")
      • order("-age") (descending sort)

      You can not sort on @Id or @Parent properties. Sort by __key__ or -__key__ instead.

      Specified by:
      order in interface Query<T>
    • translate

      protected FilterOperator translate(String operator)
      Converts the textual operator (">", "invalid input: '<'=", etc) into a FilterOperator. Forgiving about the syntax; != and invalid input: '<'> are NOT_EQUAL, = and == are EQUAL.
    • toString

      public String toString()
      Description copied from interface: SimpleQuery

      Generates a string that consistently and uniquely specifies this query. There is no way to convert this string back into a query and there is no guarantee that the string will be consistent across versions of Objectify.

      In particular, this value is useful as a key for a simple memcache query cache.

      Specified by:
      toString in interface QueryExecute<T>
      Specified by:
      toString in interface SimpleQuery<T>
      Overrides:
      toString in class Object
    • first

      public LoadResult<T> first()
      Description copied from interface: QueryExecute
      Gets the first entity in the result set. Obeys the offset value.
      Specified by:
      first in interface QueryExecute<T>
      Returns:
      an asynchronous result containing the first result. The result will hold null if the result set is empty.
    • aggregate

      public com.google.cloud.datastore.AggregationResult aggregate(com.google.cloud.datastore.aggregation.Aggregation... aggregations)
      Description copied from interface: SimpleQuery

      Run the specified aggregations given the query setup as currently defined. limit and offset are obeyed.

      Specified by:
      aggregate in interface SimpleQuery<T>
      See Also:
    • aggregate

      public com.google.cloud.datastore.AggregationResult aggregate(com.google.cloud.datastore.aggregation.AggregationBuilder<?>... aggregations)
      Description copied from interface: SimpleQuery

      Run the specified aggregations given the query setup as currently defined. limit and offset are obeyed.

      Specified by:
      aggregate in interface SimpleQuery<T>
      See Also:
    • iterable

      public QueryResultIterable<T> iterable()
      Description copied from interface: QueryExecute

      Starts an asynchronous query which will return entities.

      Note that since the Query itself is QueryResultIterable, you can iterate on the query object itself. However, if you want to start an async query and iterate on it later, you can use this method.

      Specified by:
      iterable in interface QueryExecute<T>
    • iterator

      public com.google.cloud.datastore.QueryResults<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
      Specified by:
      iterator in interface QueryResultIterable<T>
    • list

      public List<T> list()
      Description copied from interface: QueryExecute

      Execute the query and get the results as a List. The list will be equivalent to a simple ArrayList; you can iterate through it multiple times without incurring additional datastore cost.

      Note that you must be careful about limit()ing the size of the list returned; you can easily exceed the practical memory limits of Appengine by querying for a very large dataset.

      Specified by:
      list in interface QueryExecute<T>
    • clone

      public QueryImpl<T> clone()
      Overrides:
      clone in class Object