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 classIndicates 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 aQueryResultIterableis returned.asQueryResultIterable(FetchOptions fetchOptions) Similar toasIterable(FetchOptions)except aQueryResultIterableis returned.Similar toasIterator()except aQueryResultIteratoris returned.asQueryResultIterator(FetchOptions fetchOptions) Similar toasIterator(FetchOptions)except aQueryResultIteratoris returned.asQueryResultList(FetchOptions fetchOptions) Similar toasList(com.google.appengine.api.datastore.FetchOptions)except aQueryResultIteratoris returned.Retrieves the one and only result for theQuery.intDeprecated.intcountEntities(FetchOptions fetchOptions)
-
Method Details
-
asList
Retrieves theQueryEntitiesas aListusing the providedFetchOptions.Note that if
FetchOptions.getLimit()is greater than the number ofEntities, the length of the returnedListwill 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 aTransactionthat is not active.- See Also:
-
asQueryResultList
Similar toasList(com.google.appengine.api.datastore.FetchOptions)except aQueryResultIteratoris returned. -
asIterable
Retrieves theQueryEntitiesas anIterableusing 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 aTransactionthat is not active.- See Also:
-
asIterable
Equivalent toasIterable(FetchOptions)but uses defaultFetchOptions. -
asQueryResultIterable
Similar toasIterable(FetchOptions)except aQueryResultIterableis returned. Call this method to have (indirect) access toCursors for your result set. -
asQueryResultIterable
QueryResultIterable<Entity> asQueryResultIterable()Similar toasIterable()except aQueryResultIterableis returned. Call this method to have (indirect) access toCursors 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 aTransactionthat is not active.- See Also:
-
asIterator
Equivalent toasIterator(FetchOptions)but uses defaultFetchOptions. -
asQueryResultIterator
Similar toasIterator(FetchOptions)except aQueryResultIteratoris returned. Call this method to have access toCursors for your result set. -
asQueryResultIterator
QueryResultIterator<Entity> asQueryResultIterator()Similar toasIterator()except aQueryResultIteratoris returned. Call this method to have access toCursors for your result set. -
asSingleEntity
Retrieves the one and only result for theQuery.- Returns:
- the single, matching result, or
nullif no entities match - Throws:
PreparedQuery.TooManyResultsException- if more than one result is returned from theQuery.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.
-
countEntities
- Returns:
- a count >= 0
- Throws:
IllegalStateException- If the query being executed is associated with aTransactionthat 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 aTransactionthat is not active.
-
countEntities(FetchOptions)instead.