← Files AI Software ArchitectARCHIVED FILE

skills/ai-software-architect/references/data-unit-of-work.md

1.12 KB · Sep 30, 2026 · 23:15 UTC

↓ Download file

<!-- SPDX-FileCopyrightText: 2026 Leonardo Muffato (AUTOSOFT Engineering - www.autosoft-engineering.de) | SPDX-License-Identifier: MIT -->
# Unit of Work
## Intent
Track changes and coordinate their persistence within one transaction boundary.
## Problem and forces
Several repositories or objects must commit atomically and consistently.
## Applicability
Use when the persistence technology does not already expose an adequate transaction/session unit.
## When not to use
Avoid wrapping an ORM unit of work with a duplicate abstraction or spanning remote services transactionally.
## Benefits
Makes commit and rollback boundaries explicit.
## Liabilities
Long units increase contention and implicit tracking can surprise callers.
## Implementation considerations
Define ownership, nesting, retries, isolation, disposal, and interaction with domain events.
## Credible alternatives
ORM session, explicit transaction function, Saga, or Transactional Outbox.
## Related patterns
Repository, Command, Transactional Outbox.
## Architecture interview questions
What must commit atomically, and which existing component already owns that transaction?

SHA-256: f09648ae37097d6f4d63fec9392bb153124a0968a1a016581c89d37a7546347b