public abstract class

EntityManagerFactoryAccessor

extends Object
java.lang.Object
   ↳ org.springframework.orm.jpa.EntityManagerFactoryAccessor
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

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.

Summary

Fields
protected final Log logger Logger available to subclasses
Public Constructors
EntityManagerFactoryAccessor()
Public Methods
EntityManagerFactory getEntityManagerFactory()
Return the JPA EntityManagerFactory that should be used to create EntityManagers.
Map<StringObject> getJpaPropertyMap()
Allow Map access to the JPA properties to be passed to the persistence provider, with the option to add or override specific entries.
void setEntityManagerFactory(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<StringObject> jpaProperties)
Specify JPA properties as a Map, to be passed into EntityManagerFactory.createEntityManager(Map) (if any).
Protected Methods
EntityManager createEntityManager()
Obtain a new EntityManager from this accessor's EntityManagerFactory.
EntityManager getTransactionalEntityManager()
Obtain the transactional EntityManager for this accessor's EntityManagerFactory, if any.
[Expand]
Inherited Methods
From class java.lang.Object

Fields

protected final Log logger

Logger available to subclasses

Public Constructors

public EntityManagerFactoryAccessor ()

Public Methods

public EntityManagerFactory getEntityManagerFactory ()

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

public Map<StringObject> 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]".

public void setEntityManagerFactory (EntityManagerFactory emf)

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

See Also
  • javax.persistence.EntityManagerFactory#createEntityManager()
  • javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)

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
  • javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)

public void setJpaPropertyMap (Map<StringObject> 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
  • javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)

Protected Methods

protected EntityManager createEntityManager ()

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
  • javax.persistence.EntityManagerFactory#createEntityManager()
  • javax.persistence.EntityManagerFactory#createEntityManager(java.util.Map)

protected EntityManager getTransactionalEntityManager ()

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)