public interface BaseDatastoreService
DatastoreService
and AsyncDatastoreService
.Modifier and Type | Method and Description |
---|---|
java.util.Collection<Transaction> |
getActiveTransactions() |
Transaction |
getCurrentTransaction()
Returns the current transaction for this thread, or throws an exception if there is no current
transaction.
|
Transaction |
getCurrentTransaction(Transaction returnedIfNoTxn)
Returns the current transaction for this thread, or returns the parameter if there is no
current transaction.
|
PreparedQuery |
prepare(Query query)
Prepares a query for execution.
|
PreparedQuery |
prepare(Transaction txn,
Query query)
Exhibits the same behavior as
prepare(Query) , but executes within the provided
transaction. |
PreparedQuery prepare(Query query)
This method returns a PreparedQuery
which can be used to execute and retrieve
results from the datastore for query
.
This operation will not execute in a transaction even if there is a current transaction and
the provided query is an ancestor query. This operation also ignores the ImplicitTransactionManagementPolicy
. If you are preparing an ancestory query and you want it
to execute in a transaction, use prepare(Transaction, Query)
.
query
- a not null Query
.null PreparedQuery
.PreparedQuery prepare(Transaction txn, Query query)
prepare(Query)
, but executes within the provided
transaction. It is up to the caller to commit or rollback. Transaction can be null.java.lang.IllegalArgumentException
- If txn is not null and query is not an ancestor queryjava.lang.IllegalStateException
- If txn is not null and the txn is not activeTransaction getCurrentTransaction()
Use this method for when you expect there to be a current transaction and consider it an error if there isn't.
java.util.NoSuchElementException
- If there is no current transaction.Transaction getCurrentTransaction(Transaction returnedIfNoTxn)
null
or provide your own object to represent null. See
getCurrentTransaction()
for a definition of "current transaction."
Use this method when you're not sure if there is a current transaction.
returnedIfNoTxn
- The return value of this method if there is no current transaction. Can
be null.java.util.Collection<Transaction> getActiveTransactions()
Transaction
s started by this thread upon which no attempt to commit or
rollback has been made.