首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Objectify/Datastore -事务中的事务

Objectify/Datastore -事务中的事务
EN

Stack Overflow用户
提问于 2019-03-16 21:31:26
回答 1查看 103关注 0票数 0

如果将事务放入对象化/数据存储中的事务中,会发生什么情况?执行的顺序是什么?事情如何解决?

例如,

1)如果内部事务失败,外部事务也会失败吗?

( 2)如果外部事务失败,如果内部事务发生完成,内部事务会回滚吗?

代码语言:javascript
复制
// 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;
});
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-17 07:21:21

有关这方面的大量文档如下:

https://github.com/objectify/objectify/wiki/Transactions

你想问什么问题还没有回答呢?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55201687

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档