public class QueryImpl<T> extends SimpleQueryImpl<T> implements Query<T>, Cloneable
loader
Modifier and Type | Method and Description |
---|---|
QueryImpl<T> |
clone() |
int |
count()
Count the total number of values in the result.
|
QueryImpl<T> |
filter(com.google.appengine.api.datastore.Query.Filter filter)
Create a filter based on the raw low-level Filter.
|
QueryImpl<T> |
filter(String condition,
Object value)
Create a filter based on the specified condition and value, using
the same syntax as the GAE/Python query class.
|
LoadResult<T> |
first()
Gets the first entity in the result set.
|
com.google.appengine.api.datastore.QueryResultIterable<T> |
iterable()
Starts an asynchronous query which will return entities.
|
com.google.appengine.api.datastore.QueryResultIterator<T> |
iterator() |
com.google.appengine.api.datastore.QueryResultIterable<Key<T>> |
keysIterable()
Get an iterator over the keys.
|
List<T> |
list()
Execute the query and get the results as a List.
|
QueryImpl<T> |
order(String condition)
Sorts based on a property.
|
String |
toString()
Generates a string that consistently and uniquely specifies this query.
|
protected com.google.appengine.api.datastore.Query.FilterOperator |
translate(String operator)
Converts the textual operator (">", "<=", etc) into a FilterOperator.
|
ancestor, chunk, chunkAll, distinct, endAt, filterKey, filterKey, hybrid, keys, limit, offset, orderKey, project, reverse, startAt
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ancestor, chunk, chunkAll, distinct, endAt, filterKey, filterKey, hybrid, limit, offset, orderKey, project, reverse, startAt
keys
forEach, spliterator
public QueryImpl<T> filter(String condition, Object value)
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", ageList)
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.
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.
public QueryImpl<T> filter(com.google.appengine.api.datastore.Query.Filter filter)
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.
public QueryImpl<T> order(String condition)
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.
protected com.google.appengine.api.datastore.Query.FilterOperator translate(String operator)
public String toString()
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.
toString
in interface QueryExecute<T>
toString
in interface SimpleQuery<T>
toString
in class Object
public LoadResult<T> first()
QueryExecute
first
in interface QueryExecute<T>
public int count()
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.
count
in interface SimpleQuery<T>
public com.google.appengine.api.datastore.QueryResultIterable<T> iterable()
QueryExecute
Starts an asynchronous query which will return entities.
Note that since the Query
iterable
in interface QueryExecute<T>
public com.google.appengine.api.datastore.QueryResultIterator<T> iterator()
public List<T> list()
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.
list
in interface QueryExecute<T>
public com.google.appengine.api.datastore.QueryResultIterable<Key<T>> keysIterable()
Copyright © 2016. All rights reserved.