org.springframework.beans.factory.FactoryBean that creates
a local JPA jakarta.persistence.EntityManagerFactory instance within
a Spring application context.
Encapsulates the common functionality between the different JPA bootstrap contracts (standalone as well as container).
Implements support for standard JPA configuration conventions as well as
Spring's customizable JpaVendorAdapter mechanism, and controls the
EntityManagerFactory's lifecycle.
This class also implements the
org.
interface, as autodetected by Spring's
org.,
for AOP-based translation of native exceptions to Spring DataAccessExceptions.
Hence, the presence of e.g. LocalEntityManagerFactoryBean automatically enables
a PersistenceExceptionTranslationPostProcessor to translate JPA exceptions.
LocalEntityManagerFactoryBean, LocalContainerEntityManagerFactoryBean
| Modifier and Type | Class and Description |
|---|---|
| private static class | AbstractEntityManagerFactoryBean.ManagedEntityManagerFactoryInvocationHandler
Dynamic proxy invocation handler for an |
| private static class | AbstractEntityManagerFactoryBean.SerializedEntityManagerFactoryBeanReference
Minimal bean reference to the surrounding AbstractEntityManagerFactoryBean. |
| Modifier and Type | Field and Description |
|---|---|
| private ClassLoader | |
| private BeanFactory | |
| private String | |
| private AsyncTaskExecutor | |
| private EntityManagerFactory | entityManagerFactory
Exposed client-level EntityManagerFactory proxy. |
| private Class | |
| private Consumer | |
| private Class | |
| private JpaDialect | |
| private final Map | |
| private JpaVendorAdapter | |
| protected final Log | logger
Logger available to subclasses. |
| private EntityManagerFactory | nativeEntityManagerFactory
Raw EntityManagerFactory as returned by the PersistenceProvider. |
| private Future | nativeEntityManagerFactoryFuture
Future for lazily initializing raw target EntityManagerFactory. |
| private PersistenceProvider | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | afterPropertiesSet()
Implements org. BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware, ApplicationContextAware etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. |
| private EntityManagerFactory | |
| protected EntityManagerFactory | Returns: the EntityManagerFactory proxythe EntityManagerFactory as returned by the persistence provider,
if initialized already emf)Create a proxy for the given |
| public EntityManager | createNativeEntityManager(Map<?, ?> properties)
Implements org. |
| protected abstract EntityManagerFactory | Returns: the EntityManagerFactory instance returned by this FactoryBeanSubclasses must implement this method to create the EntityManagerFactory
that will be returned by the |
| public void | destroy()
Implements org. |
| public ClassLoader | getBeanClassLoader()
Implements org. |
| public AsyncTaskExecutor | |
| public DataSource | getDataSource()
Implements org. |
| public Class | getEntityManagerInterface()
Implements org. |
| public JpaDialect | getJpaDialect()
Implements org. null if not known.
|
| public Map | getJpaPropertyMap()
Allow |
| public JpaVendorAdapter | getJpaVendorAdapter()
Return the JpaVendorAdapter implementation for this EntityManagerFactory,
or |
| public EntityManagerFactory | getNativeEntityManagerFactory()
Implements org. |
| public EntityManagerFactory | getObject()
Implements org. |
| public Class | getObjectType()
Implements org. null if not known in advance.
|
| public PersistenceProvider | getPersistenceProvider()
Implements org. |
| public PersistenceUnitInfo | getPersistenceUnitInfo()
Implements org. |
| public String | getPersistenceUnitName()
Implements org. null if it is an unnamed default.
|
| pack-priv Object | invokeProxyMethod(Method method, Object[] args)
Delegate an incoming invocation from the proxy, dispatching to EntityManagerFactoryInfo or the native EntityManagerFactory accordingly. |
| public boolean | isSingleton()
Overrides default org. |
| protected void | postProcessEntityManager(EntityManager
the EntityManager to post-process rawEntityManager)Optional callback for post-processing the native EntityManager before active use. |
| private void | |
| public void | setBeanClassLoader(ClassLoader
the owning class loader classLoader)Implements org. class loader to
a bean instance.
|
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. |
| public void | setBeanName(String
the name of the bean in the factory.
Note that this name is the actual bean name used in the factory, which may
differ from the originally specified name: in particular for inner bean
names, the actual bean name might have been made unique through appending
"#..." suffixes. Use the name)BeanFactoryUtils#originalBeanName(String)
method to extract the original bean name (without suffix), if desired.Implements org. |
| public void | setBootstrapExecutor(AsyncTaskExecutor bootstrapExecutor)
Specify an asynchronous executor for background bootstrapping,
e.g. a |
| public void | setEntityManagerFactoryInterface(Class<? extends EntityManagerFactory> emfInterface)
Specify the (potentially vendor-specific) EntityManagerFactory interface that this EntityManagerFactory proxy is supposed to implement. |
| public void | setEntityManagerInitializer(Consumer<EntityManager> entityManagerInitializer)
Specify a callback for customizing every |
| public void | setEntityManagerInterface(Class<? extends EntityManager> emInterface)
Specify the (potentially vendor-specific) EntityManager interface that this factory's EntityManagers are supposed to implement. |
| public void | setJpaDialect(JpaDialect jpaDialect)
Specify the vendor-specific JpaDialect implementation to associate with this EntityManagerFactory. |
| public void | setJpaProperties(Properties jpaProperties)
Specify JPA properties, to be passed into
|
| public void | setJpaPropertyMap(Map<String, ?> jpaProperties)
Specify JPA properties as a Map, to be passed into
|
| public void | setJpaVendorAdapter(JpaVendorAdapter jpaVendorAdapter)
Specify the JpaVendorAdapter implementation for the desired JPA provider, if any. |
| public void | setPersistenceProvider(PersistenceProvider persistenceProvider)
Set the PersistenceProvider instance to use for creating the EntityManagerFactory. |
| public void | setPersistenceProviderClass(Class<? extends PersistenceProvider> persistenceProviderClass)
Set the PersistenceProvider implementation class to use for creating the EntityManagerFactory. |
| public void | setPersistenceUnitName(String persistenceUnitName)
Specify the name of the EntityManagerFactory configuration. |
| public DataAccessException | translateExceptionIfPossible(RuntimeException
a RuntimeException to translate ex)Implements org. |
| protected Object |