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
-
-
Field Summary
-
Fields inherited from class com.googlecode.objectify.impl.SimpleQueryImpl
loader
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QueryImpl<T>
clone()
int
count()
Count the total number of values in the result.QueryImpl<T>
filter(com.google.cloud.datastore.StructuredQuery.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.QueryResultIterable<T>
iterable()
Starts an asynchronous query which will return entities.com.google.cloud.datastore.QueryResults<T>
iterator()
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.googlecode.objectify.impl.FilterOperator
translate(String operator)
Converts the textual operator (">", "<=", 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, startAt
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface com.googlecode.objectify.cmd.Query
ancestor, chunk, chunkAll, distinct, endAt, filterKey, filterKey, hybrid, limit, offset, orderKey, project, startAt
-
Methods inherited from interface com.googlecode.objectify.cmd.SimpleQuery
keys
-
-
-
-
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()
orancestor()
instead.
-
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 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.
-
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.
-
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 interfaceQueryExecute<T>
- Specified by:
toString
in interfaceSimpleQuery<T>
- Overrides:
toString
in classObject
-
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 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: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 interfaceSimpleQuery<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 interfaceQueryExecute<T>
-
iterator
public com.google.cloud.datastore.QueryResults<T> iterator()
-
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 interfaceQueryExecute<T>
-
-