What is the purpose of the rollback method in the Unit of Work template?

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

Q: . So why is so much documentation about the Unit of Work template related to the Commit and Rollback methods?

These concepts mean nothing to the domain or to domain experts. A business transaction can be “completed,” and therefore UnitOfWork must provide a “Full” method. Similarly, instead of the Rollback method, should it not be modeled as "Clear"?

Update:

Answer: Both answers below are correct. These are two options for registering UoW: registration of objects and registration of the caller. When registering an object, Rollback is used to undo changes for all objects in memory. When registering the caller, Rollback serves to clear all recorded changes, so a subsequent call to Commit will do nothing.

+5
source share
2 answers

Unit of Work, , Fowler - relational. , Evans Domain Driven Design.

, -, , - , commit(). "" "" - - , . , - - - , ( ) .

- , . , . Unit of Work commit() , rollback() , . , "", .

, "" "" "--" . "" "" , , -. "" - , . Service Layer Aggregate Root.

+2

. , "" "", ( , ). , "". "", . , , "" -. "" - , .

+1

All Articles