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

## org.springframework.orm.jpa
Class EntityManagerFactoryAccessor

    java.lang.Object
      org.springframework.orm.jpa.EntityManagerFactoryAccessor

Direct Known Subclasses:
  JpaAccessor, OpenEntityManagerInViewInterceptor, SharedEntityManagerBean

    public abstract class EntityManagerFactoryAccessor

extends Object

Base class for any class that needs to access an EntityManagerFactory, usually in order to obtain an EntityManager. Defines common properties.

Not intended to be used directly. See `JpaAccessor`.

Since:
  2.0
Author:
  Juergen Hoeller
See Also:
  `JpaAccessor`, `EntityManagerFactoryUtils`

Field Summary
`protected Log` | `logger` Logger available to subclasses

Constructor Summary
`EntityManagerFactoryAccessor()`

Method Summary
`protected javax.persistence.EntityManager` | `createEntityManager()` Obtain a new EntityManager from this accessor's EntityManagerFactory.
`javax.persistence.EntityManagerFactory` | `getEntityManagerFactory()` Return the JPA EntityManagerFactory that should be used to create EntityManagers.
`Map<String,Object>` | `getJpaPropertyMap()` Allow Map access to the JPA properties to be passed to the persistence provider, with the option to add or override specific entries.
`protected javax.persistence.EntityManager` | `getTransactionalEntityManager()` Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any.
`void` | `setEntityManagerFactory(javax.persistence.EntityManagerFactory emf)` Set the JPA EntityManagerFactory that should be used to create EntityManagers.
`void` | `setJpaProperties(Properties jpaProperties)` Specify JPA properties, to be passed into `EntityManagerFactory.createEntityManager(Map)` (if any).
`void` | `setJpaPropertyMap(Map<String,Object> jpaProperties)` Specify JPA properties as a Map, to be passed into `EntityManagerFactory.createEntityManager(Map)` (if any).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### logger

    protected final Log logger

  Logger available to subclasses

Constructor Detail

### EntityManagerFactoryAccessor

    public EntityManagerFactoryAccessor()

Method Detail

### setEntityManagerFactory

    public void setEntityManagerFactory(javax.persistence.EntityManagerFactory emf)

  Set the JPA EntityManagerFactory that should be used to create EntityManagers.

  See Also:
    `EntityManagerFactory.createEntityManager()`, `EntityManagerFactory.createEntityManager(java.util.Map)`

### getEntityManagerFactory

    public javax.persistence.EntityManagerFactory getEntityManagerFactory()

  Return the JPA EntityManagerFactory that should be used to create EntityManagers.

### setJpaProperties

    public void setJpaProperties(Properties jpaProperties)

  Specify JPA properties, to be passed into `EntityManagerFactory.createEntityManager(Map)` (if any).

  Can be populated with a String "value" (parsed via PropertiesEditor) or a "props" element in XML bean definitions.

  See Also:
    `EntityManagerFactory.createEntityManager(java.util.Map)`

### setJpaPropertyMap

    public void setJpaPropertyMap(Map<String,Object> jpaProperties)

  Specify JPA properties as a Map, to be passed into `EntityManagerFactory.createEntityManager(Map)` (if any).

  Can be populated with a "map" or "props" element in XML bean definitions.

  See Also:
    `EntityManagerFactory.createEntityManager(java.util.Map)`

### getJpaPropertyMap

    public Map<String,Object> getJpaPropertyMap()

  Allow Map access to the JPA properties to be passed to the persistence provider, with the option to add or override specific entries.

  Useful for specifying entries directly, for example via "jpaPropertyMap[myKey]".

### createEntityManager

    protected javax.persistence.EntityManager createEntityManager()
                                                           throws IllegalStateException

  Obtain a new EntityManager from this accessor's EntityManagerFactory.

  Can be overridden in subclasses to create specific EntityManager variants.

  Returns:
    a new EntityManager
  Throws:
    `IllegalStateException` - if this accessor is not configured with an EntityManagerFactory
  See Also:
    `EntityManagerFactory.createEntityManager()`, `EntityManagerFactory.createEntityManager(java.util.Map)`

### getTransactionalEntityManager

    protected javax.persistence.EntityManager getTransactionalEntityManager()
                                                                     throws IllegalStateException

  Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any.

  Returns:
    the transactional EntityManager, or `null` if none
  Throws:
    `IllegalStateException` - if this accessor is not configured with an EntityManagerFactory
  See Also:
    `EntityManagerFactoryUtils.getTransactionalEntityManager(javax.persistence.EntityManagerFactory)`, `EntityManagerFactoryUtils.getTransactionalEntityManager(javax.persistence.EntityManagerFactory, java.util.Map)`

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