When we load objects from the database and change them, it is important to keep track of what we have changed; otherwise, the changed objects won't be written to the database. Furthermore, new objects have to be added to the database and objects we delete have to be removed from the database.
A Unit of Work (UoW) is used to keep track of everything that happens during a business transaction and that affects the database. It keeps track of every single step needed to update the database once the business transaction is completed. The UoW guarantees that the individual database operations needed to update the system are executed in the right order, to avoid any database constraint violations.
In NHibernate, we have the
Session object, ...