org.springframework.orm.jpa

## Class ExtendedEntityManagerCreator

- java.lang.Object
- - org.springframework.orm.jpa.ExtendedEntityManagerCreator

    public abstract class ExtendedEntityManagerCreator
    extends Object

Factory for dynamic EntityManager proxies that follow the JPA spec's semantics for "extended" EntityManagers.

Supports explicit joining of a transaction through the `joinTransaction()` method ("application-managed extended EntityManager") as well as automatic joining on each operation ("container-managed extended EntityManager").

Since:
  2.0
Author:
  Rod Johnson, Juergen Hoeller

### Constructor Summary

Constructors
Constructor and Description
`ExtendedEntityManagerCreator()`

### Method Summary

Methods
`static EntityManager` `createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)` Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.
`static EntityManager` `createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerPlusOperations plusOperations)` Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.
`static EntityManager` `createApplicationManagedEntityManager(EntityManager rawEntityManager, EntityManagerPlusOperations plusOperations, PersistenceExceptionTranslator exceptionTranslator)` Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.
`static EntityManager` `createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerFactoryInfo emfInfo)` Create an EntityManager that automatically joins transactions on each operation in a transaction.
`static EntityManager` `createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerPlusOperations plusOperations)` Create an EntityManager that automatically joins transactions on each operation in a transaction.
`static EntityManager` `createContainerManagedEntityManager(EntityManager rawEntityManager, EntityManagerPlusOperations plusOperations, PersistenceExceptionTranslator exceptionTranslator)` Create an EntityManager that automatically joins transactions on each operation in a transaction.
`static EntityManager` `createContainerManagedEntityManager(EntityManagerFactory emf)` Create an EntityManager that automatically joins transactions on each operation in a transaction.
`static EntityManager` `createContainerManagedEntityManager(EntityManagerFactory emf, Map properties)` Create an EntityManager that automatically joins transactions on each operation in a transaction.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ExtendedEntityManagerCreator

    public ExtendedEntityManagerCreator()

### Method Detail

#### createApplicationManagedEntityManager

    public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager,
                                                      EntityManagerPlusOperations plusOperations)

Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.

Parameters:
  `rawEntityManager` - raw EntityManager
  `plusOperations` - an implementation of the EntityManagerPlusOperations interface, if those operations should be exposed (may be `null`)
Returns:
  an application-managed EntityManager that can join transactions but does not participate in them automatically

#### createApplicationManagedEntityManager

    public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager,
                                                      EntityManagerPlusOperations plusOperations,
                                                      PersistenceExceptionTranslator exceptionTranslator)

Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.

Parameters:
  `rawEntityManager` - raw EntityManager
  `plusOperations` - an implementation of the EntityManagerPlusOperations interface, if those operations should be exposed (may be `null`)
  `exceptionTranslator` - the exception translator to use for translating JPA commit/rollback exceptions during transaction synchronization (may be `null`)
Returns:
  an application-managed EntityManager that can join transactions but does not participate in them automatically

#### createApplicationManagedEntityManager

    public static EntityManager createApplicationManagedEntityManager(EntityManager rawEntityManager,
                                                      EntityManagerFactoryInfo emfInfo)

Create an EntityManager that can join transactions with the `joinTransaction()` method, but is not automatically managed by the container.

Parameters:
  `rawEntityManager` - raw EntityManager
  `emfInfo` - the EntityManagerFactoryInfo to obtain the EntityManagerPlusOperations and PersistenceUnitInfo from
Returns:
  an application-managed EntityManager that can join transactions but does not participate in them automatically

#### createContainerManagedEntityManager

    public static EntityManager createContainerManagedEntityManager(EntityManager rawEntityManager,
                                                    EntityManagerPlusOperations plusOperations)

Create an EntityManager that automatically joins transactions on each operation in a transaction.

Parameters:
  `rawEntityManager` - raw EntityManager
  `plusOperations` - an implementation of the EntityManagerPlusOperations interface, if those operations should be exposed (may be `null`)
Returns:
  a container-managed EntityManager that will automatically participate in any managed transaction

#### createContainerManagedEntityManager

    public static EntityManager createContainerManagedEntityManager(EntityManager rawEntityManager,
                                                    EntityManagerPlusOperations plusOperations,
                                                    PersistenceExceptionTranslator exceptionTranslator)

Create an EntityManager that automatically joins transactions on each operation in a transaction.

Parameters:
  `rawEntityManager` - raw EntityManager
  `plusOperations` - an implementation of the EntityManagerPlusOperations interface, if those operations should be exposed (may be `null`)
  `exceptionTranslator` - the exception translator to use for translating JPA commit/rollback exceptions during transaction synchronization (may be `null`)
Returns:
  a container-managed EntityManager that will automatically participate in any managed transaction

#### createContainerManagedEntityManager

    public static EntityManager createContainerManagedEntityManager(EntityManager rawEntityManager,
                                                    EntityManagerFactoryInfo emfInfo)

Create an EntityManager that automatically joins transactions on each operation in a transaction.

Parameters:
  `rawEntityManager` - raw EntityManager
  `emfInfo` - the EntityManagerFactoryInfo to obtain the EntityManagerPlusOperations and PersistenceUnitInfo from
Returns:
  a container-managed EntityManager that will automatically participate in any managed transaction

#### createContainerManagedEntityManager

    public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf)

Create an EntityManager that automatically joins transactions on each operation in a transaction.

Parameters:
  `emf` - the EntityManagerFactory to create the EntityManager with. If this implements the EntityManagerFactoryInfo interface, appropriate handling of the native EntityManagerFactory and available EntityManagerPlusOperations will automatically apply.
Returns:
  a container-managed EntityManager that will automatically participate in any managed transaction
See Also:
  `EntityManagerFactory.createEntityManager()`

#### createContainerManagedEntityManager

    public static EntityManager createContainerManagedEntityManager(EntityManagerFactory emf,
                                                    Map properties)

Create an EntityManager that automatically joins transactions on each operation in a transaction.

Parameters:
  `emf` - the EntityManagerFactory to create the EntityManager with. If this implements the EntityManagerFactoryInfo interface, appropriate handling of the native EntityManagerFactory and available EntityManagerPlusOperations will automatically apply.
  `properties` - the properties to be passed into the `createEntityManager` call (may be `null`)
Returns:
  a container-managed EntityManager that will automatically participate in any managed transaction
See Also:
  `EntityManagerFactory.createEntityManager(java.util.Map)`