知识卡片

普通读书笔记卡 · 1971.o.1.b.4.d.1.c.4.a.3.a.4

仓储通常不自行提交事务

理解等级:中级

仓储负责把聚合加入或移出存储,但通常不在每次保存后自行提交事务。调用方掌握一次业务操作的完整上下文,适合决定工作单元何时开始和提交;仓储若提前提交,会把本应一起完成的变更拆开。这里的“调用方”是原书对事务边界责任的表述,具体应用仍须结合现有事务框架设计。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 原书第06章|Repositories · 查看原书依据

      Although the REPOSITORY will insert into and delete from the database, it will ordinarily not commit anything. It is tempting to commit after saving, for example, but the client presumably has the context to correctly initiate and commit units of work.

    参考来源

    - 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第46章《原书第06章|Repositories》(源文件:_epub-src/0321125215_ch06lev1sec3.html;小节 Implementing a Repository) - 结论依据:原文明确要求仓储把事务控制留给调用方,虽执行插入和删除,通常不自行提交,因为调用方有开启及提交工作单元的上下文。 - 原始内容:Although the REPOSITORY will insert into and delete from the database, it will ordinarily not commit anything. It is tempting to commit after saving, for example, but the client presumably has the context to correctly initiate and commit units of work.