This illustration shows the interaction amongst the objects used when you use a Unit of Work in a JTA environment when an external transaction does not exists. The Application calls the Session method getActiveUnitOfWork. The Unit of Work calls the Container and tries to associate itself with an External Transaction. The Container has no External Transaction and so the Session returns a null to the Application. The Application logic responds by then calling the Session method acquireUnitOfWork. The Unit of Work requests a new transaction from the Container which in turn creates an External Transaction. The Session returns a non-null Unit of Work to the Application. The Application uses the Unit of Work and when it is done, it does call commit. The Unit of Work then requests the Container to commit. The Container commits the transaction and at the appropriate time, the Container calls the Unit of Work call-back method beforeCompletion. The Unit of Work then writes its SQL to the database. When the commit ends (either successfully or not), the Container calls the Unit of Work call-back method afterCompletion, passing in a boolean result parameter. The Unit of Work examines the result. If the result is true, the commit was successful and the Unit of Work merges changes to the Session cache. If the result is false, the commit was unsuccessful and the Unit of Work does not merge changes to the Session cache.