Interface PreparedQuery
-
public interface PreparedQueryContains methods for fetching and returning entities from aQuery. If theQueryspecified a sort order,Entitiesare returned in that order. Otherwise, the order is undefined.A
PreparedQuerydoes not cache results. Each use ofPreparedQueryresults in a new trip to the datastore.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface and Description static classPreparedQuery.TooManyResultsExceptionIndicates that too many results were found forasSingleEntity().
-
Method Summary
-
-
-
Method Detail
-
asList
java.util.List<Entity> asList(FetchOptions fetchOptions)
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:
java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.- See Also:
FetchOptions
-
asQueryResultList
QueryResultList<Entity> asQueryResultList(FetchOptions fetchOptions)
Similar toasList(com.google.appengine.api.datastore.FetchOptions)except aQueryResultIteratoris returned.
-
asIterable
java.lang.Iterable<Entity> asIterable(FetchOptions fetchOptions)
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:
java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.- See Also:
FetchOptions
-
asQueryResultIterable
QueryResultIterable<Entity> asQueryResultIterable(FetchOptions fetchOptions)
Similar toasIterable(FetchOptions)except aQueryResultIterableis returned. Call this method to have (indirect) access toCursors for your result set.
-
asIterable
java.lang.Iterable<Entity> asIterable()
Equivalent toasIterable(FetchOptions)but uses defaultFetchOptions.
-
asQueryResultIterable
QueryResultIterable<Entity> asQueryResultIterable()
Similar toasIterable()except aQueryResultIterableis returned. Call this method to have (indirect) access toCursors for your result set.
-
asIterator
java.util.Iterator<Entity> asIterator(FetchOptions fetchOptions)
- Parameters:
fetchOptions- The fetch strategy to apply.- Returns:
- The result of the PreparedQuery, represented as an
Iterator. - Throws:
java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.- See Also:
FetchOptions
-
asIterator
java.util.Iterator<Entity> asIterator()
Equivalent toasIterator(FetchOptions)but uses defaultFetchOptions.
-
asQueryResultIterator
QueryResultIterator<Entity> asQueryResultIterator(FetchOptions fetchOptions)
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
Entity asSingleEntity() throws PreparedQuery.TooManyResultsException
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.java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.
-
countEntities
int countEntities(FetchOptions fetchOptions)
- Returns:
- a count >= 0
- Throws:
java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.
-
countEntities
@Deprecated int countEntities()
Deprecated. UsecountEntities(FetchOptions)instead. Calling this function imposes a maximum result limit of 1000.- Returns:
- a count >= 0
- Throws:
java.lang.IllegalStateException- If the query being executed is associated with aTransactionthat is not active.
-
-