如果将事务放入对象化/数据存储中的事务中,会发生什么情况?执行的顺序是什么?事情如何解决?
例如,
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;
});发布于 2019-03-17 07:21:21
https://stackoverflow.com/questions/55201687
复制相似问题