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]
}
Aggregations