Skip to main content

Unit Of Work Implementer

Implement Unit of Work (UoW) — the object that tracks new, dirty, clean, and removed entities during a business operation and commits all database changes together in the correct order. Use when asked: "how do I implement Unit of Work?", "how does Hibernate Session work under the hood?", "how do I avoid N+1 writes?", "how should I structure DbContext scoping?", "SQLAlchemy session management best practices", "EntityManager lifecycle", "ORM session management", "how to track entity changes in a Data Mapper layer?", "first-level cache", "identity map implementation", "object change tracking", "persistence coordination", "commit ordering with foreign keys", "how does EF Core SaveChanges work?", "dirty tracking", "how to batch database writes?", "UoW pattern implementation", "Hibernate Session vs EntityManager", "SQLAlchemy Session scope", "DbContext per-request", "entity state tracking". Applies when a Data Mapper pattern is in place (or being introduced) and the team needs disciplined change tracking, ordered commits, and first-level caching across a business operation. Integrates with Identity Map for cache and identity consistency. Integrates with Optimistic Offline Lock via version-conditioned UPDATE. Prerequisite: Data Mapper must be the chosen data-source pattern; UoW does not apply cleanly to Active Record (AR handles per-object persistence without a coordinator). If the data-source pattern has not been chosen, invoke `data-source-pattern-selector` first.

Install

1. Add marketplace
/plugin marketplace add bookforge-ai/bookforge-skills
2. Install plugin
/plugin install patterns-of-enterprise-application-architecture@bookforge-skills
3. Use the skill
/unit-of-work-implementer
CC-BY-SA · Open sourceGitHub

What You'll Need

ReadWriteGrep

Source Book

Patterns of Enterprise Application Architecture cover

Patterns of Enterprise Application Architecture

Martin Fowler, David Rice, Matthew Foemmel, Edward Hieatt, Robert Mee, Randy Stafford