Message-ID: <2052983890.1405.1432845113158.JavaMail.firstname.lastname@example.org> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_1404_1344551432.1432845113158" ------=_Part_1404_1344551432.1432845113158 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The Unit Of Work pattern is a common pattern in enterpr= ise application architectures.=20
It can be used for implementing:=20
It implements the concept of an "application transaction" that= keeps track of:=20
It records the state of the objects, by tracking field changes, as it is= before the transaction is started and will then rollback the state in memo= ry upon rollback of the transaction. It allows adding additional behavior a= t commit, rollback etc., for example store all new, updat= e all dirty and remove all removed objects in a persistent storage.=20
Fowler defines the Unit Of Work pattern like this in his book Patterns of Enterprise Application Architecture:==20
"Maintains a list of objects affected by a business transaction and= coordinates the writing out of changes and the resolution of concurrency p= roblems."
This implementation implements the following transaction semantics:= =20
The user can implement listeners that allows him to trigger additional b= ehaviour on specific events, such as begin, commit, r= ollback, dispose etc.=20
All listeners must implement that
The Unit Of Work will not commit until all listeners have agreed on that= . If for example on listener have set the transaction to rollBackOnly= em> then the whole Unit Of Work transaction will rollback.=20 =20
We also provide a convenience abstract adapter class that you can use if=
you are only interested in implementing a couple of methods and don't want=
to have empty method definitions. Just extend the
The listeners are added to the Unit Of Work in the
But in practice it is usually best to define this information outside th= e code, in a configuration file. Such as in the HibernateUnitOfWorkListener implementation,= which uses the SpringAspe= ctContainer to configure the UnitOfWork.