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.
Dynamic proxy invocation handler for an |
| private static class | AbstractEntityManagerFactoryBean.
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. Invoked by the containing 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. Create a native JPA EntityManager to be used as the framework-managed resource behind an application-level EntityManager handle. |
| 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. Close the EntityManagerFactory on bean factory shutdown. |
| public ClassLoader | getBeanClassLoader()
Implements org. Return the ClassLoader that the application's beans are loaded with. |
| public AsyncTaskExecutor | |
| public DataSource | getDataSource()
Implements org. Return the JDBC DataSource that this EntityManagerFactory obtains its JDBC Connections from. |
| public Class | getEntityManagerInterface()
Implements org. Return the (potentially vendor-specific) EntityManager interface that this factory's EntityManagers will implement. |
| public JpaDialect | getJpaDialect()
Implements org. Return the vendor-specific JpaDialect implementation for this
EntityManagerFactory, or |
| public Map | getJpaPropertyMap()
Allow |
| public JpaVendorAdapter | getJpaVendorAdapter()
Return the JpaVendorAdapter implementation for this EntityManagerFactory,
or |
| public EntityManagerFactory | getNativeEntityManagerFactory()
Implements org. Return the raw underlying EntityManagerFactory. |
| public EntityManagerFactory | getObject()
Implements org. Return the singleton EntityManagerFactory. |
| public Class | getObjectType()
Implements org. Return the type of object that this FactoryBean creates,
or |
| public PersistenceProvider | getPersistenceProvider()
Implements org. Return the underlying PersistenceProvider that the underlying EntityManagerFactory was created with. |
| public PersistenceUnitInfo | getPersistenceUnitInfo()
Implements org. Return the PersistenceUnitInfo used to create this EntityManagerFactory, if the in-container API was used. |
| public String | getPersistenceUnitName()
Implements org. Return the name of the persistence unit used to create this
EntityManagerFactory, or |
| 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. Is the object managed by this factory a singleton? |
| 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. Callback that supplies the bean |
| public void | setBeanFactory(BeanFactory
owning BeanFactory (never beanFactory)null).
The bean can immediately call methods on the factory.Implements org. Callback that supplies the owning factory to a bean instance. |
| 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. Set the name of the bean in the bean factory that created this bean. |
| 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. Implementation of the PersistenceExceptionTranslator interface, as autodetected by Spring's PersistenceExceptionTranslationPostProcessor. |
| protected Object |