org.apache.cayenne.jpa
Class JtaEntityManager

java.lang.Object
  extended by org.apache.cayenne.jpa.ResourceLocalEntityManager
      extended by org.apache.cayenne.jpa.JtaEntityManager
All Implemented Interfaces:
CayenneEntityManager

public class JtaEntityManager
extends ResourceLocalEntityManager

An EntityManager that can participate in JTA transactions.

Author:
Andrus Adamchik

Field Summary
protected  Object currentTxKey
           
 
Fields inherited from class org.apache.cayenne.jpa.ResourceLocalEntityManager
context, factory, flushMode, open, transaction
 
Constructor Summary
JtaEntityManager(ObjectContext context, JtaEntityManagerFactory factory)
           
 
Method Summary
protected  void checkTransaction()
           
 void flush()
          Synchronize the persistence context to the underlying database.
 EntityTransaction getTransaction()
          Return the resource-level transaction object.
 void joinTransaction()
          Indicates to the EntityManager that a JTA transaction is active.
<T> T
merge(T entity)
          Merge the state of the given entity into the current persistence context.
 void persist(Object entity)
          Make an instance managed and persistent.
 void refresh(Object entity)
          Refresh the state of the instance from the database, overwriting changes made to the entity, if any.
 void remove(Object entity)
          Remove the entity instance.
 
Methods inherited from class org.apache.cayenne.jpa.ResourceLocalEntityManager
checkAttached, checkClosed, checkNotRemoved, clear, close, contains, createNamedQuery, createNativeQuery, createNativeQuery, createNativeQuery, createQuery, find, getChannel, getDelegate, getFactory, getFlushMode, getReference, isOpen, lock, setFlushMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentTxKey

protected Object currentTxKey
Constructor Detail

JtaEntityManager

public JtaEntityManager(ObjectContext context,
                        JtaEntityManagerFactory factory)
Method Detail

getTransaction

public EntityTransaction getTransaction()
Description copied from class: ResourceLocalEntityManager
Return the resource-level transaction object. The EntityTransaction instance may be used serially to begin and commit multiple transactions.

Overrides:
getTransaction in class ResourceLocalEntityManager
Returns:
EntityTransaction instance
Throws:
IllegalStateException, - as this entity manager is of JTA kind.

joinTransaction

public void joinTransaction()
Indicates to the EntityManager that a JTA transaction is active. This method should be called on a JTA application managed EntityManager that was created outside the scope of the active transaction to associate it with the current JTA transaction.

Overrides:
joinTransaction in class ResourceLocalEntityManager
Throws:
TransactionRequiredException - if there is no transaction.

persist

public void persist(Object entity)
Description copied from class: ResourceLocalEntityManager
Make an instance managed and persistent.

Overrides:
persist in class ResourceLocalEntityManager
Parameters:
entity - an object to be made persistent
Throws:
TransactionRequiredException - if there is no transaction.

merge

public <T> T merge(T entity)
Description copied from class: ResourceLocalEntityManager
Merge the state of the given entity into the current persistence context. Cayenne: Is this like localObject(s)?

Overrides:
merge in class ResourceLocalEntityManager
Returns:
the instance that the state was merged to
Throws:
TransactionRequiredException - if there is no transaction.

remove

public void remove(Object entity)
Description copied from class: ResourceLocalEntityManager
Remove the entity instance.

Overrides:
remove in class ResourceLocalEntityManager
Throws:
TransactionRequiredException - if there is no transaction.

refresh

public void refresh(Object entity)
Description copied from class: ResourceLocalEntityManager
Refresh the state of the instance from the database, overwriting changes made to the entity, if any.

Overrides:
refresh in class ResourceLocalEntityManager
Throws:
TransactionRequiredException - if there is no transaction.

flush

public void flush()
Description copied from class: ResourceLocalEntityManager
Synchronize the persistence context to the underlying database.

Overrides:
flush in class ResourceLocalEntityManager
Throws:
TransactionRequiredException - if there is no transaction.

checkTransaction

protected void checkTransaction()
                         throws TransactionRequiredException
Throws:
TransactionRequiredException - if there is no transaction in progress.


Copyright © 2001-2007 Apache Cayenne. All Rights Reserved.