Class QueryImpl<T>
- All Implemented Interfaces:
Query<T>,QueryExecute<T>,QueryResultIterable<T>,SimpleQuery<T>,Cloneable,Iterable<T>
- Author:
- Jeff Schnitzer invalid input: '<'[email protected]>
-
Field Summary
Fields inherited from class com.googlecode.objectify.impl.SimpleQueryImpl
loader -
Method Summary
Modifier and TypeMethodDescriptionclone()intcount()Count the total number of values in the result.filter(com.google.cloud.datastore.StructuredQuery.Filter filter) Create a filter based on the raw low-level Filter.Create an arbitrarily complex filter.Create a filter based on the specified condition and value, using the same syntax as the GAE/Python query class.first()Gets the first entity in the result set.iterable()Starts an asynchronous query which will return entities.com.google.cloud.datastore.QueryResults<T>iterator()list()Execute the query and get the results as a List.Sorts based on a property.toString()Generates a string that consistently and uniquely specifies this query.protected FilterOperatorConverts the textual operator (">", "invalid input: '<'=", etc) into a FilterOperator.Methods inherited from class com.googlecode.objectify.impl.SimpleQueryImpl
ancestor, chunk, chunkAll, distinct, endAt, filterKey, filterKey, hybrid, keys, limit, offset, orderKey, project, startAtMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.googlecode.objectify.cmd.Query
ancestor, chunk, chunkAll, distinct, endAt, filterKey, filterKey, hybrid, limit, offset, orderKey, project, startAtMethods inherited from interface com.googlecode.objectify.cmd.QueryExecute
streamMethods inherited from interface com.googlecode.objectify.cmd.SimpleQuery
keys
-
Method Details
-
filter
Description copied from interface:QueryCreate 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()orancestor()instead. -
filter
Description copied from interface:QueryCreate 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
Keyobjects and not ObjectifyKey<?>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()orancestor()instead. -
filter
Description copied from interface:QueryCreate 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<?>andRef<?>.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. -
order
Description copied from interface:QuerySorts 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.
-
translate
Converts the textual operator (">", "invalid input: '<'=", etc) into a FilterOperator. Forgiving about the syntax; != and invalid input: '<'> are NOT_EQUAL, = and == are EQUAL. -
toString
Description copied from interface:SimpleQueryGenerates 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:
toStringin interfaceQueryExecute<T>- Specified by:
toStringin interfaceSimpleQuery<T>- Overrides:
toStringin classObject
-
first
Description copied from interface:QueryExecuteGets the first entity in the result set. Obeys the offset value.- Specified by:
firstin interfaceQueryExecute<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:SimpleQueryCount 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:
countin interfaceSimpleQuery<T>
-
iterable
Description copied from interface:QueryExecuteStarts 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:
iterablein interfaceQueryExecute<T>
-
iterator
-
list
Description copied from interface:QueryExecuteExecute 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:
listin interfaceQueryExecute<T>
-
clone
-