com.google.inject.persist
Interface UnitOfWork


public interface UnitOfWork

This interface is used to gain manual control over the unit of work. This is mostly to do work in non-request, non-transactional threads. Or where more fine-grained control over the unit of work is required. Starting and ending a unit of work directly corresponds to opening and closing a Session, EntityManager or ObjectContainer respectively.

The Unit of Work referred to by UnitOfWork will always be local to the calling thread. Be careful to end() in a finally block. Neither JPA, nor Hibernate supports threadsafe sessions (reasoning behind thread-locality of Unit of Work semantics).

Author:
Dhanji R. Prasanna (dhanji@gmail com)

Method Summary
 void begin()
          Starts a Unit Of Work.
 void end()
          Declares an end to the current Unit of Work.
 

Method Detail

begin

void begin()
Starts a Unit Of Work. Underneath, causes a session to the data layer to be opened. If there is already one open, the invocation will do nothing. In this way, you can define arbitrary units-of-work that nest within one another safely. Transaction semantics are not affected.


end

void end()
Declares an end to the current Unit of Work. Underneath, causes any open session to the data layer to close. If there is no Unit of work open, then the call returns silently. You can safely invoke end() repeatedly.

Transaction semantics are not affected.



Copyright © 2006-2011 Google, Inc.. All Rights Reserved.