Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3793472
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:46:51+00:00 2026-05-19T12:46:51+00:00

As I understand it, a UnitOfWork class is meant to represent the concept of

  • 0

As I understand it, a UnitOfWork class is meant to represent the concept of a business transaction in the domain. It’s not directly supposed to represent a database transaction, which is a detail of only one possible implementation.

Q: So why does so much documentation about the Unit of Work pattern refer to “Commit” and “Rollback” methods?

These concepts mean nothing to the domain, or to domain experts. A business transaction can be “completed”, and therefore the UnitOfWork should provide a “Complete” method. Likewise, instead of a “Rollback” method, shouldn’t it be modeled as “Clear”?

Update:

Answer: Both answers below are correct. Their are two variants of UoW: object registration and caller registration. In object registration, Rollback serves to undo changes to all in-memory objects. In caller registration, Rollback serves to clear all recorded changes such that subsequent call to Commit will do nothing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:46:52+00:00Added an answer on May 19, 2026 at 12:46 pm

    The Unit of Work design pattern, at least as defined by Fowler in Patterns of Enterprise Application Architecture – is an implementation detail concerning object-relational persistence mapping. It is not an entity defined in Evans’ Domain Driven Design.

    As such, it should neither be part of the business discussion, nor an entity that’s directly exposed in a domain model – perhaps excepting the commit() method. Instead its intent is tracking “clean” and “dirty” business entities – the objects from a domain model exposed to clients. The purpose is allowing multiple interactions – in web context requests – with a domain model without the need to read and write from persistence (usually a database) each time.

    Business entities call it when their methods are called. When their state is altered, they register themselves as dirty with the Unit of Work. Then the Unit of Work’s commit() handles the entire persistence transaction in terms of writing out the object graph and rollback() means restoring the state of entities to what they were. So its very much the implementation leaking through to the “abstraction”, but its intent is very clear.

    On the other hand, “Undo” and “Complete” don’t necessarily map one-to-one with this definition. An “Undo” or “Clear” may only rollback an object graph partially for instance depending on the business context. While “Complete” may well be altering state on some entity as well as committing the graph. As such I would put these methods, with business meaning, on a Service Layer or Aggregate Root object.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using EF4 POCOs and UnitOfWork/repository patterns with MVC 3. I'm trying to understand
I don't understand, here is my problem : string sql=alter table mytable add CellarPosition
Understand that 1x1 widget size should be 72 dip x 72 dip, but this
I understand that if else staments should say stuff like: if dog equals one,
I understand that @synthesize window; combined with @property 'auto-creates' your setters and getters, but
I'm using NHibernate, DI/IoC and the Unit of Work pattern. Most UoW examples I've
So using some assistance from tutorials I have managed to wire up a Nhibernate
I've encountered what seems to be a common problem: I am updating values in
I'm still trying to get my head around mocking. Right now, I'm trying to
I am still having a hard time wrapping my head around this. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.