Class QueryImpl<T>

    • Method Detail

      • 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)

        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>
      • 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 com.googlecode.objectify.impl.FilterOperator translate​(String operator)
        Converts the textual operator (">", "<=", etc) into a FilterOperator. Forgiving about the syntax; != and <> 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.
      • count

        public int count()
        Description copied from interface: SimpleQuery

        Count the total number of values in the result. limit and offset are obeyed. This is somewhat faster than fetching, but the time still grows with the number of results. The datastore actually walks through the result set and counts for you.

        Immediately executes the query; there is no async version of this method.

        WARNING: Each counted entity is billed as a "datastore minor operation". Even though these are free, they may take significant time because they require an index walk.

        Specified by:
        count in interface SimpleQuery<T>
      • 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>
      • 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>