如果将交易放入objectify / datastore中的交易中会发生什么?执行的顺序是什么,如何解决?
例如,
1)如果内部事务失败,外部事务也会失败吗?
2)如果外部事务失败,内部事务是否恰好会回滚?
// Outer Transaction
Thing th = ofy().transact(() -> {
Thing thing = ofy().load().key(thingKey).now();
thing.modify();
ofy().save().entity(thing);
// Inner Transaction
// This transaction could be in another method used in various other places
Thing th2 = ofy().transact(() -> {
Thing thing2 = ofy().load().key(thingKey2).now();
thing2.modify();
Thing thing2 = ofy().load().key(thingKey3).now();
thing3.modify();
ofy().save().entity(thing2);
ofy().save().entity(thing3);
return thing;
});
return thing;
});
答案 0 :(得分:0)