【发布时间】:2013-12-16 23:35:25
【问题描述】:
我刚刚注意到 XG 事务的 docs' example 使用包含事务作为参数的 put 方法,但它没有提到这样做的必要性。
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();
根据API,单参数put(和get)使用事务:
如果有当前事务,该操作将在 那笔交易
我担心 XG 交易。如果我在该示例中只使用为两个实体放置的单个参数(并且我有很多这样的代码),它们是否仍会在 XG 事务中执行?
【问题讨论】:
标签: java google-app-engine transactions google-cloud-datastore