ユニットオブワークとは?
ユニットオブワークは、単一の操作内で読み込まれたり変更されたりしたすべてのオブジェクトを記録し、操作が完了したときにまとめて書き出すパターンです。変更を1つのトランザクションに協調させ、挿入、更新、削除の順序を決定します。何かが失敗した場合は、その一式全体を1単位としてロールバックできます。
なぜ重要か
関連する変更を1つのトランザクションにまとめることで、データの一貫性を保ち、往復を減らします。操作全体をコミットするか破棄するかの明確な境界を与えます。
関連ガイド
What Is the Repository Pattern?The repository pattern provides a collection-like interface for accessing domain objects, hiding the details…
What Is a Data Mapper?A data mapper is a layer that moves data between objects and a database while keeping the two independent, so…
What Is Optimistic Locking?Optimistic locking detects conflicting updates at commit time by checking a version field, rather than holdin…