org.apache.james.mailbox.jpa
Class JPATransactionalMapper

java.lang.Object
  extended by org.apache.james.mailbox.store.transaction.TransactionalMapper
      extended by org.apache.james.mailbox.jpa.JPATransactionalMapper
All Implemented Interfaces:
Mapper
Direct Known Subclasses:
JPAMailboxMapper, JPAMessageMapper, JPASubscriptionMapper

public abstract class JPATransactionalMapper
extends TransactionalMapper

JPA implementation of TransactionMapper. This class is not thread-safe!


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.james.mailbox.store.transaction.Mapper
Mapper.MailboxMembershipCallback<Id>, Mapper.Transaction<T>, Mapper.VoidTransaction
 
Field Summary
protected  javax.persistence.EntityManager entityManager
           
protected  javax.persistence.EntityManagerFactory entityManagerFactory
           
 
Constructor Summary
JPATransactionalMapper(javax.persistence.EntityManagerFactory entityManagerFactory)
           
 
Method Summary
protected  void begin()
           
protected  void commit()
          Commit the Transaction and close the EntityManager
 void endRequest()
          Close open EntityManager
 javax.persistence.EntityManager getEntityManager()
          Return the currently used EntityManager or a new one if none exists.
protected  void rollback()
           
 
Methods inherited from class org.apache.james.mailbox.store.transaction.TransactionalMapper
execute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityManagerFactory

protected javax.persistence.EntityManagerFactory entityManagerFactory

entityManager

protected javax.persistence.EntityManager entityManager
Constructor Detail

JPATransactionalMapper

public JPATransactionalMapper(javax.persistence.EntityManagerFactory entityManagerFactory)
Method Detail

getEntityManager

public javax.persistence.EntityManager getEntityManager()
Return the currently used EntityManager or a new one if none exists.

Returns:
entitymanger

begin

protected void begin()
              throws MailboxException
Specified by:
begin in class TransactionalMapper
Throws:
MailboxException

commit

protected void commit()
               throws MailboxException
Commit the Transaction and close the EntityManager

Specified by:
commit in class TransactionalMapper
Throws:
MailboxException

rollback

protected void rollback()
                 throws MailboxException
Specified by:
rollback in class TransactionalMapper
Throws:
MailboxException

endRequest

public void endRequest()
Close open EntityManager



Copyright © 2010-2011 The Apache Software Foundation. All Rights Reserved.