public interface Query<T> extends SimpleQuery<T>
Modifier and Type | Method and Description |
---|---|
Query<T> |
ancestor(Object keyOrEntity)
Restricts result set only to objects which have the given ancestor
somewhere in the chain.
|
Query<T> |
chunk(int value)
Sets the internal chunking and prefetching strategy within the low-level API.
|
Query<T> |
chunkAll()
Sets the internal chunking and prefetching strategy within the low-level API to attempt to get all
results at once.
|
Query<T> |
distinct(boolean value)
Determines whether this is a SELECT DISTINCT query.
|
Query<T> |
endAt(com.google.appengine.api.datastore.Cursor value)
Ends query results at the specified Cursor.
|
Query<T> |
filter(com.google.appengine.api.datastore.Query.Filter filter)
Create a filter based on the raw low-level Filter.
|
Query<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.
|
Query<T> |
filterKey(Object value)
An alias for
filterKey("=", value) |
Query<T> |
filterKey(String condition,
Object value)
Create a filter on the key of an entity.
|
Query<T> |
hybrid(boolean force)
This method forces Objectify to (or not to) hybridize the query into a keys-only fetch plus batch get.
|
Query<T> |
limit(int value)
Limit the fetched result set to a certain number of values.
|
Query<T> |
offset(int value)
Starts the query results at a particular zero-based offset.
|
Query<T> |
order(String condition)
Sorts based on a property.
|
Query<T> |
orderKey(boolean descending)
Shorthand for
order("__key__") or order("-__key__") |
Query<T> |
project(String... fields)
Converts this query into a projection query.
|
Query<T> |
reverse()
Reverse the query, as described in the GAE docs.
|
Query<T> |
startAt(com.google.appengine.api.datastore.Cursor value)
Starts query results at the specified Cursor.
|
count, keys, toString
first, iterable, list
forEach, spliterator
Query<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. 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.
Query<T> filter(com.google.appengine.api.datastore.Query.Filter filter)
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.
Query<T> filterKey(String condition, Object value)
SimpleQuery
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.
filterKey
in interface SimpleQuery<T>
Query<T> filterKey(Object value)
SimpleQuery
filterKey("=", value)
All command objects are immutable; this method returns a new object instead of modifying the current command object.
filterKey
in interface SimpleQuery<T>
Query<T> order(String condition)
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.
Query<T> orderKey(boolean descending)
order("__key__")
or order("-__key__")
orderKey
in interface SimpleQuery<T>
descending
- if true, specifies a descending (aka reverse) sortQuery<T> ancestor(Object keyOrEntity)
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
ancestor
in interface SimpleQuery<T>
keyOrEntity
- can be a Key, a KeyQuery<T> limit(int value)
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
limit
in interface SimpleQuery<T>
value
- must be >= 0. A value of 0 indicates no limit.Query<T> offset(int value)
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
offset
in interface SimpleQuery<T>
value
- must be >= 0Query<T> startAt(com.google.appengine.api.datastore.Cursor value)
SimpleQuery
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.startAt
in interface SimpleQuery<T>
Query<T> endAt(com.google.appengine.api.datastore.Cursor value)
SimpleQuery
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.endAt
in interface SimpleQuery<T>
Query<T> chunk(int value)
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
chunk
in interface SimpleQuery<T>
value
- must be >= 0Query<T> chunkAll()
SimpleQuery
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).
chunkAll
in interface SimpleQuery<T>
Query<T> hybrid(boolean force)
SimpleQuery
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.
hybrid
in interface SimpleQuery<T>
Query<T> reverse()
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
reverse
in interface SimpleQuery<T>
Query<T> project(String... fields)
SimpleQuery
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.
project
in interface SimpleQuery<T>
fields
- is one or more field namesQuery<T> distinct(boolean value)
SimpleQuery
All command objects are immutable; this method returns a new object instead of modifying the current command object.
distinct
in interface SimpleQuery<T>
Copyright © 2015. All rights reserved.