public interface SimpleQuery<T> extends QueryExecute<T>
Modifier and Type | Method and Description |
---|---|
SimpleQuery<T> |
ancestor(Object keyOrEntity)
Restricts result set only to objects which have the given ancestor
somewhere in the chain.
|
SimpleQuery<T> |
chunk(int value)
Sets the internal chunking and prefetching strategy within the low-level API.
|
SimpleQuery<T> |
chunkAll()
Sets the internal chunking and prefetching strategy within the low-level API to attempt to get all
results at once.
|
int |
count()
Count the total number of values in the result.
|
SimpleQuery<T> |
distinct(boolean value)
Determines whether this is a SELECT DISTINCT query.
|
SimpleQuery<T> |
endAt(com.google.appengine.api.datastore.Cursor value)
Ends query results at the specified Cursor.
|
SimpleQuery<T> |
filterKey(Object value)
An alias for
filterKey("=", value) |
SimpleQuery<T> |
filterKey(String condition,
Object value)
Create a filter on the key of an entity.
|
SimpleQuery<T> |
hybrid(boolean force)
This method forces Objectify to (or not to) hybridize the query into a keys-only fetch plus batch get.
|
QueryKeys<T> |
keys()
Switches to a keys-only query.
|
SimpleQuery<T> |
limit(int value)
Limit the fetched result set to a certain number of values.
|
SimpleQuery<T> |
offset(int value)
Starts the query results at a particular zero-based offset.
|
SimpleQuery<T> |
orderKey(boolean descending)
Orders results by the key.
|
SimpleQuery<T> |
project(String... fields)
Converts this query into a projection query.
|
SimpleQuery<T> |
reverse()
Reverse the query, as described in the GAE docs.
|
SimpleQuery<T> |
startAt(com.google.appengine.api.datastore.Cursor value)
Starts query results at the specified Cursor.
|
String |
toString()
Generates a string that consistently and uniquely specifies this query.
|
first, iterable, list
forEach, spliterator
SimpleQuery<T> filterKey(String condition, Object value)
Create a filter on the key of an entity. Examples:
filterKey(">=", key)
(standard inequalities)filterKey("=", key)
(wouldn't you rather do a load-by-key?)filterKey("", key)
(if no operator, = is assumed)filterKey("!=", key)
filterKey("in", keyList)
(wouldn't you rather do a batch load-by-key?)The key parameter can be anything key-ish; a Key>, a native datastore key, a Ref, a pojo entity, etc.
See the Google documentation for indexes for an explanation of what you can and cannot filter for.
All command objects are immutable; this method returns a new object instead of modifying the current command object.
SimpleQuery<T> filterKey(Object value)
filterKey("=", value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
SimpleQuery<T> orderKey(boolean descending)
descending
- if true, specifies a descending (aka reverse) sort
All command objects are immutable; this method returns a new object instead of modifying the current command object.
SimpleQuery<T> ancestor(Object keyOrEntity)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
keyOrEntity
- can be a Key, a KeySimpleQuery<T> limit(int value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
value
- must be >= 0. A value of 0 indicates no limit.SimpleQuery<T> offset(int value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
value
- must be >= 0SimpleQuery<T> startAt(com.google.appengine.api.datastore.Cursor value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
Note that limit() and offset() are NOT encoded within a cursor; they operate on the results of the query after a cursor is established.SimpleQuery<T> endAt(com.google.appengine.api.datastore.Cursor value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
Note that limit() and offset() are NOT encoded within a cursor; they operate on the results of the query after a cursor is established.SimpleQuery<T> chunk(int value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
value
- must be >= 0SimpleQuery<T> chunkAll()
Sets the internal chunking and prefetching strategy within the low-level API to attempt to get all results at once. Affects performance only; the result set will be the same.
All command objects are immutable; this method returns a new object instead of modifying the current command object.
Same as chunk(Integer.MAX_VALUE).
SimpleQuery<T> project(String... fields)
Converts this query into a projection query. Projection queries allow values to be selected directly out of an index rather than loading the whole entity. While this allows data to be fetched quickly and cheaply, it is limited to selecting data that exists in an index.
Entities returned from projection queries are NOT kept in the session cache. However, @Load annotations are processed normally.
This method can be called more than once; it will have the same effect as passing all the fields in to a single call.
fields
- is one or more field namesSimpleQuery<T> distinct(boolean value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
SimpleQuery<T> reverse()
All command objects are immutable; this method returns a new object instead of modifying the current command object.
SimpleQuery<T> hybrid(boolean force)
This method forces Objectify to (or not to) hybridize the query into a keys-only fetch plus batch get.
If Objectify knows you are fetching an entity type that can be cached, it automatically converts queries into a "hybrid" of keys-only query followed by a batch fetch of the keys. This is cheaper (keys-only results are 1/7th the price of a full fetch) and, if the cache hits, significantly faster. However, there are some circumstances in which you may wish to force behavior one way or another:
For the most part, hybridization only affects the performance and cost of queries. However, it is possible
for hybridization to alter the content of the result set. In the HRD, queries
always have EVENTUAL consistency but get operations may have either STRONG or EVENTUAL consistency depending
on the read policy (see Objectify.consistency()
. The keys-only query results will always be EVENTUAL and may
return data that has been deleted, but Objectify will exclude these results when the more-current batch get fails to return
data. So the count of the returned data may actually be less than the limit(), even if there are plenty of
actual results. hybrid(false)
will prevent this behavior.
Note that in hybrid queries, the chunk size defines the batch size.
All command objects are immutable; this method returns a new object instead of modifying the current command object.
QueryKeys<T> keys()
All command objects are immutable; this method returns a new object instead of modifying the current command object.
int count()
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.
String toString()
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 class Object
Copyright © 2016. All rights reserved.