{@link org.springframework.beans.factory.FactoryBean} that creates a JPA{@link javax.persistence.EntityManagerFactory} according to JPA's standard
container bootstrap contract. This is the most powerful way to set up a shared JPA EntityManagerFactory in a Spring application context; the EntityManagerFactory can then be passed to JPA-based DAOs via dependency injection. Note that switching to a JNDI lookup or to a {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean}definition is just a matter of configuration!
As with {@link LocalEntityManagerFactoryBean}, configuration settings are usually read in from a META-INF/persistence.xml
config file, residing in the class path, according to the general JPA configuration contract. However, this FactoryBean is more flexible in that you can override the location of the persistence.xml
file, specify the JDBC DataSources to link to, etc. Furthermore, it allows for pluggable class instrumentation through Spring's {@link org.springframework.instrument.classloading.LoadTimeWeaver} abstraction,instead of being tied to a special VM agent specified on JVM startup.
Internally, this FactoryBean parses the persistence.xml
file itself and creates a corresponding {@link javax.persistence.spi.PersistenceUnitInfo}object (with further configuration merged in, such as JDBC DataSources and the Spring LoadTimeWeaver), to be passed to the chosen JPA {@link javax.persistence.spi.PersistenceProvider}. This corresponds to a local JPA container with full support for the standard JPA container contract.
The exposed EntityManagerFactory object will implement all the interfaces of the underlying native EntityManagerFactory returned by the PersistenceProvider, plus the {@link EntityManagerFactoryInfo} interface which exposes additionalmetadata as assembled by this FactoryBean.
@author Juergen Hoeller
@author Rod Johnson
@since 2.0
@see #setPersistenceXmlLocation
@see #setJpaProperties
@see #setJpaVendorAdapter
@see #setLoadTimeWeaver
@see #setDataSource
@see EntityManagerFactoryInfo
@see LocalEntityManagerFactoryBean
@see org.springframework.orm.jpa.support.SharedEntityManagerBean
@see javax.persistence.spi.PersistenceProvider#createContainerEntityManagerFactory