Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne.jpa
Class JtaEntityManager

    java.lang.Object
      org.apache.cayenne.jpa.ResourceLocalEntityManager
          org.apache.cayenne.jpa.JtaEntityManager

All Implemented Interfaces:
  javax.persistence.EntityManager, 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.
`javax.persistence.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 javax.persistence.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.

  Specified by:
    `getTransaction` in interface `javax.persistence.EntityManager`
  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.

  Specified by:
    `joinTransaction` in interface `javax.persistence.EntityManager`
  Overrides:
    `joinTransaction` in class `ResourceLocalEntityManager`
  Throws:
    `javax.persistence.TransactionRequiredException` - if there is no transaction.

### persist

    public void persist(Object entity)

  Description copied from class: `ResourceLocalEntityManager`
  Make an instance managed and persistent.

  Specified by:
    `persist` in interface `javax.persistence.EntityManager`
  Overrides:
    `persist` in class `ResourceLocalEntityManager`
  Parameters:
    `entity` - an object to be made persistent
  Throws:
    `javax.persistence.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)?

  Specified by:
    `merge` in interface `javax.persistence.EntityManager`
  Overrides:
    `merge` in class `ResourceLocalEntityManager`
  Returns:
    the instance that the state was merged to
  Throws:
    `javax.persistence.TransactionRequiredException` - if there is no transaction.

### remove

    public void remove(Object entity)

  Description copied from class: `ResourceLocalEntityManager`
  Remove the entity instance.

  Specified by:
    `remove` in interface `javax.persistence.EntityManager`
  Overrides:
    `remove` in class `ResourceLocalEntityManager`
  Throws:
    `javax.persistence.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.

  Specified by:
    `refresh` in interface `javax.persistence.EntityManager`
  Overrides:
    `refresh` in class `ResourceLocalEntityManager`
  Throws:
    `javax.persistence.TransactionRequiredException` - if there is no transaction.

### flush

    public void flush()

  Description copied from class: `ResourceLocalEntityManager`
  Synchronize the persistence context to the underlying database.

  Specified by:
    `flush` in interface `javax.persistence.EntityManager`
  Overrides:
    `flush` in class `ResourceLocalEntityManager`
  Throws:
    `javax.persistence.TransactionRequiredException` - if there is no transaction.

### checkTransaction

    protected void checkTransaction()
                             throws javax.persistence.TransactionRequiredException

  Throws:
    `javax.persistence.TransactionRequiredException` - if there is no transaction in progress.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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