Search in sources :

Example 1 with TransactionOptions

use of com.google.appengine.api.datastore.TransactionOptions in project java-docs-samples by GoogleCloudPlatform.

the class TransactionsTest method crossGroupTransactions.

@Test
public void crossGroupTransactions() throws Exception {
    // [START cross-group_XG_transactions_using_the_Java_low-level_API]
    DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
    TransactionOptions options = TransactionOptions.Builder.withXG(true);
    Transaction txn = datastore.beginTransaction(options);
    Entity a = new Entity("A");
    a.setProperty("a", 22);
    datastore.put(txn, a);
    Entity b = new Entity("B");
    b.setProperty("b", 11);
    datastore.put(txn, b);
    txn.commit();
// [END cross-group_XG_transactions_using_the_Java_low-level_API]
}
Also used : Entity(com.google.appengine.api.datastore.Entity) Transaction(com.google.appengine.api.datastore.Transaction) TransactionOptions(com.google.appengine.api.datastore.TransactionOptions) DatastoreService(com.google.appengine.api.datastore.DatastoreService) Test(org.junit.Test)

Aggregations

DatastoreService (com.google.appengine.api.datastore.DatastoreService)1 Entity (com.google.appengine.api.datastore.Entity)1 Transaction (com.google.appengine.api.datastore.Transaction)1 TransactionOptions (com.google.appengine.api.datastore.TransactionOptions)1 Test (org.junit.Test)1