Interface PreparedQuery
public interface PreparedQuery
Contains methods for fetching and returning entities from a
Query
. If the Query
specified a sort order, Entities
are returned in that order. Otherwise, the order
is undefined.
A PreparedQuery
does not cache results. Each use of PreparedQuery
results in a
new trip to the datastore.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
Indicates that too many results were found forasSingleEntity()
. -
Method Summary
Modifier and TypeMethodDescriptionEquivalent toasIterable(FetchOptions)
but uses defaultFetchOptions
.asIterable
(FetchOptions fetchOptions) Equivalent toasIterator(FetchOptions)
but uses defaultFetchOptions
.asIterator
(FetchOptions fetchOptions) asList
(FetchOptions fetchOptions) Similar toasIterable()
except aQueryResultIterable
is returned.asQueryResultIterable
(FetchOptions fetchOptions) Similar toasIterable(FetchOptions)
except aQueryResultIterable
is returned.Similar toasIterator()
except aQueryResultIterator
is returned.asQueryResultIterator
(FetchOptions fetchOptions) Similar toasIterator(FetchOptions)
except aQueryResultIterator
is returned.asQueryResultList
(FetchOptions fetchOptions) Similar toasList(com.google.appengine.api.datastore.FetchOptions)
except aQueryResultIterator
is returned.Retrieves the one and only result for theQuery
.int
Deprecated.int
countEntities
(FetchOptions fetchOptions)
-
Method Details
-
asList
Retrieves theQuery
Entities
as aList
using the providedFetchOptions
.Note that if
FetchOptions.getLimit()
is greater than the number ofEntities
, the length of the returnedList
will be smaller thanFetchOptions.getLimit()
.To operate on large result sets, you should prefer
asIterable(com.google.appengine.api.datastore.FetchOptions)
andasIterator(com.google.appengine.api.datastore.FetchOptions)
, which stream the results from the datastore.- Parameters:
fetchOptions
- The fetch options to apply.- Returns:
- The result of the PreparedQuery, represented as a
List
. - Throws:
IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.- See Also:
-
asQueryResultList
Similar toasList(com.google.appengine.api.datastore.FetchOptions)
except aQueryResultIterator
is returned. -
asIterable
Retrieves theQuery
Entities
as anIterable
using the providedFetchOptions
.Each use of
Iterable.iterator()
results in an entirely new and independentIterator
.- Parameters:
fetchOptions
- The fetch options to apply.- Returns:
- The result of the PreparedQuery, represented as an
Iterable
. - Throws:
IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.- See Also:
-
asIterable
Equivalent toasIterable(FetchOptions)
but uses defaultFetchOptions
. -
asQueryResultIterable
Similar toasIterable(FetchOptions)
except aQueryResultIterable
is returned. Call this method to have (indirect) access toCursor
s for your result set. -
asQueryResultIterable
QueryResultIterable<Entity> asQueryResultIterable()Similar toasIterable()
except aQueryResultIterable
is returned. Call this method to have (indirect) access toCursor
s for your result set. -
asIterator
- Parameters:
fetchOptions
- The fetch strategy to apply.- Returns:
- The result of the PreparedQuery, represented as an
Iterator
. - Throws:
IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.- See Also:
-
asIterator
Equivalent toasIterator(FetchOptions)
but uses defaultFetchOptions
. -
asQueryResultIterator
Similar toasIterator(FetchOptions)
except aQueryResultIterator
is returned. Call this method to have access toCursor
s for your result set. -
asQueryResultIterator
QueryResultIterator<Entity> asQueryResultIterator()Similar toasIterator()
except aQueryResultIterator
is returned. Call this method to have access toCursor
s for your result set. -
asSingleEntity
Retrieves the one and only result for theQuery
.- Returns:
- the single, matching result, or
null
if no entities match - Throws:
PreparedQuery.TooManyResultsException
- if more than one result is returned from theQuery
.IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.
-
countEntities
- Returns:
- a count >= 0
- Throws:
IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.
-
countEntities
Deprecated.UsecountEntities(FetchOptions)
instead. Calling this function imposes a maximum result limit of 1000.- Returns:
- a count >= 0
- Throws:
IllegalStateException
- If the query being executed is associated with aTransaction
that is not active.
-
countEntities(FetchOptions)
instead.