|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.googlecode.objectify.impl.QueryImpl<T>
public class QueryImpl<T>
Implementation of Query.
Nested Class Summary | |
---|---|
protected class |
QueryImpl.ToKeyIterable
Iterable that translates from datastore Entity to Keys |
protected class |
QueryImpl.ToKeyIterator
Iterator that translates from datastore Entity to Keys |
protected class |
QueryImpl.ToObjectIterable
Iterable that translates from datastore Entity to POJO |
protected class |
QueryImpl.ToObjectIterator
Iterator that translates from datastore Entity to typed Objects |
Constructor Summary | |
---|---|
QueryImpl(ObjectifyFactory fact,
Objectify objectify)
|
|
QueryImpl(ObjectifyFactory fact,
Objectify objectify,
java.lang.Class<T> clazz)
|
Method Summary | ||
---|---|---|
Query<T> |
ancestor(java.lang.Object keyOrEntity)
Restricts result set only to objects which have the given ancestor somewhere in the chain. |
|
Query<T> |
chunkSize(int value)
Sets the internal chunking strategy within the low-level API. |
|
Query<T> |
clone()
|
|
protected com.google.appengine.api.datastore.Query |
cloneRawQuery(com.google.appengine.api.datastore.Query orig)
Make a new Query object that is exactly like the old. |
|
int |
count()
Count the total number of values in the result. |
|
Query<T> |
endCursor(com.google.appengine.api.datastore.Cursor value)
Ends query results at the specified Cursor. |
|
com.google.appengine.api.datastore.QueryResultIterable<T> |
fetch()
Starts an asynchronous query. |
|
com.google.appengine.api.datastore.QueryResultIterable<Key<T>> |
fetchKeys()
Prepares an Iterable that will obtain the keys of the results. |
|
|
fetchParentKeys()
Execute a keys-only query and then extract parent keys, returning them as a Set. |
|
|
fetchParents()
Gets the parent keys and then fetches the actual entities. |
|
Query<T> |
filter(java.lang.String condition,
java.lang.Object value)
Create a filter based on the specified condition and value, using the same syntax as the GAE/Python query class. |
|
T |
get()
Gets the first entity in the result set. |
|
protected com.google.appengine.api.datastore.Query |
getActual()
|
|
Key<T> |
getKey()
Get the key of the first entity in the result set. |
|
com.google.appengine.api.datastore.QueryResultIterator<T> |
iterator()
|
|
Query<T> |
limit(int value)
Limit the fetched result set to a certain number of values. |
|
java.util.List<T> |
list()
Execute the query and get the results as a List. |
|
java.util.List<Key<T>> |
listKeys()
Execute a keys-only query and get the results as a List. |
|
Query<T> |
offset(int value)
Starts the query results at a particular zero-based offset. |
|
Query<T> |
order(java.lang.String condition)
Sorts based on a property. |
|
Query<T> |
prefetchSize(int value)
Sets the number of results retreived on the first call to the datastore. |
|
Query<T> |
startCursor(com.google.appengine.api.datastore.Cursor value)
Starts query results at the specified Cursor. |
|
java.lang.String |
toString()
Generates a string that consistently and uniquely specifies this query. |
|
protected com.google.appengine.api.datastore.Query.FilterOperator |
translate(java.lang.String operator)
Converts the textual operator (">", "<=", etc) into a FilterOperator. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public QueryImpl(ObjectifyFactory fact, Objectify objectify)
public QueryImpl(ObjectifyFactory fact, Objectify objectify, java.lang.Class<T> clazz)
Method Detail |
---|
protected com.google.appengine.api.datastore.Query getActual()
public Query<T> filter(java.lang.String condition, java.lang.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 is required. Filtering a condition of
"age>="
will perform an equality test on an entity property
with that exact name. You can't create properties like this with Objectify,
but you can with the Low-Level API.
See the Google documentation for indexes for an explanation of what you can and cannot filter for.
In addition to filtering on indexed properties, you can filter on @Id properties
if this query is restricted to a Class
You can not filter on @Parent properties. Use
the ancestor()
method instead.
filter
in interface Query<T>
protected com.google.appengine.api.datastore.Query.FilterOperator translate(java.lang.String operator)
public Query<T> order(java.lang.String condition)
Query
Sorts based on a property. Examples:
order("age")
order("-age")
(descending sort)You can sort on id properties if this query is
restricted to a Class
You can not sort on @Parent properties.
order
in interface Query<T>
public Query<T> ancestor(java.lang.Object keyOrEntity)
Query
ancestor
in interface Query<T>
keyOrEntity
- can be a Key, a Keypublic Query<T> limit(int value)
Query
limit
in interface Query<T>
value
- must be >= 0. A value of 0 indicates no limit.public Query<T> offset(int value)
Query
offset
in interface Query<T>
value
- must be >= 0public Query<T> startCursor(com.google.appengine.api.datastore.Cursor value)
Query
startCursor
in interface Query<T>
public Query<T> endCursor(com.google.appengine.api.datastore.Cursor value)
Query
endCursor
in interface Query<T>
public Query<T> chunkSize(int value)
Query
chunkSize
in interface Query<T>
value
- must be > 0public Query<T> prefetchSize(int value)
Query
prefetchSize
in interface Query<T>
value
- must be >= 0public java.lang.String toString()
Query
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 Query<T>
toString
in class java.lang.Object
public com.google.appengine.api.datastore.QueryResultIterator<T> iterator()
iterator
in interface com.google.appengine.api.datastore.QueryResultIterable<T>
iterator
in interface java.lang.Iterable<T>
public T get()
Query
get
in interface Query<T>
public Key<T> getKey()
Query
getKey
in interface Query<T>
public int count()
Query
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.
count
in interface Query<T>
public com.google.appengine.api.datastore.QueryResultIterable<T> fetch()
Query
fetch
in interface Query<T>
public com.google.appengine.api.datastore.QueryResultIterable<Key<T>> fetchKeys()
Query
fetchKeys
in interface Query<T>
public <V> java.util.Set<Key<V>> fetchParentKeys()
Query
fetchParentKeys
in interface Query<T>
public <V> java.util.Map<Key<V>,V> fetchParents()
Query
ofy.get(query.fetchParentKeys())
.
fetchParents
in interface Query<T>
public java.util.List<T> list()
Query
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 Query<T>
public java.util.List<Key<T>> listKeys()
Query
Execute a keys-only query and get the results as a List. This is more efficient than fetching the actual results.
The size and scope considerations of list() apply; don't fetch more data than you can fit in a simple ArrayList.
listKeys
in interface Query<T>
public Query<T> clone()
clone
in interface Query<T>
clone
in class java.lang.Object
protected com.google.appengine.api.datastore.Query cloneRawQuery(com.google.appengine.api.datastore.Query orig)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |