类 LocalEntityManagerFactoryBean
- java.lang.Object
- org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
- org.springframework.orm.jpa.LocalEntityManagerFactoryBean
- 所有已实现的接口:
Serializable,Aware,BeanClassLoaderAware,BeanFactoryAware,BeanNameAware,DisposableBean,FactoryBean<EntityManagerFactory>,InitializingBean,PersistenceExceptionTranslator,EntityManagerFactoryInfo
public class LocalEntityManagerFactoryBean extends AbstractEntityManagerFactoryBean
FactoryBeanthat creates a JPAEntityManagerFactoryaccording to JPA's standard standalone bootstrap contract. This is the simplest 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 aLocalContainerEntityManagerFactoryBeandefinition is just a matter of configuration!Configuration settings are usually read from a
META-INF/persistence.xmlconfig file, residing in the class path, according to the JPA standalone bootstrap contract. Additionally, most JPA providers will require a special VM agent (specified on JVM startup) that allows them to instrument application classes. See the Java Persistence API specification and your provider documentation for setup details.This EntityManagerFactory bootstrap is appropriate for standalone applications which solely use JPA for data access. If you want to set up your persistence provider for an external DataSource and/or for global transactions which span multiple resources, you will need to either deploy it into a full Java EE application server and access the deployed EntityManagerFactory via JNDI, or use Spring's
LocalContainerEntityManagerFactoryBeanwith appropriate configuration for local setup according to JPA's container contract.Note: This FactoryBean has limited configuration power in terms of what configuration it is able to pass to the JPA provider. If you need more flexible configuration, for example passing a Spring-managed JDBC DataSource to the JPA provider, consider using Spring's more powerful
LocalContainerEntityManagerFactoryBeaninstead.NOTE: Spring's JPA support requires JPA 2.0 or higher, as of Spring 4.0. JPA 1.0 based applications are still supported; however, a JPA 2.0/2.1 compliant persistence provider is needed at runtime.
- 从以下版本开始:
- 2.0
- 作者:
- Juergen Hoeller, Rod Johnson
- 另请参阅:
AbstractEntityManagerFactoryBean.setJpaProperties(java.util.Properties),AbstractEntityManagerFactoryBean.setJpaVendorAdapter(org.springframework.orm.jpa.JpaVendorAdapter),JpaTransactionManager.setEntityManagerFactory(javax.persistence.EntityManagerFactory),LocalContainerEntityManagerFactoryBean,JndiObjectFactoryBean,SharedEntityManagerBean,Persistence.createEntityManagerFactory(java.lang.String),PersistenceProvider.createEntityManagerFactory(java.lang.String, java.util.Map), 序列化表格
字段概要
从类继承的字段 org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
logger
构造器概要
构造器 构造器 说明 LocalEntityManagerFactoryBean()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected EntityManagerFactorycreateNativeEntityManagerFactory()Initialize the EntityManagerFactory for the given configuration.从类继承的方法 org.springframework.orm.jpa.AbstractEntityManagerFactoryBean
afterPropertiesSet, createEntityManagerFactoryProxy, destroy, getBeanClassLoader, getBootstrapExecutor, getDataSource, getEntityManagerInterface, getJpaDialect, getJpaPropertyMap, getJpaVendorAdapter, getNativeEntityManagerFactory, getObject, getObjectType, getPersistenceProvider, getPersistenceUnitInfo, getPersistenceUnitName, isSingleton, setBeanClassLoader, setBeanFactory, setBeanName, setBootstrapExecutor, setEntityManagerFactoryInterface, setEntityManagerInterface, setJpaDialect, setJpaProperties, setJpaPropertyMap, setJpaVendorAdapter, setPersistenceProvider, setPersistenceProviderClass, setPersistenceUnitName, translateExceptionIfPossible, writeReplace
构造器详细资料
LocalEntityManagerFactoryBean
public LocalEntityManagerFactoryBean()
方法详细资料
createNativeEntityManagerFactory
protected EntityManagerFactory createNativeEntityManagerFactory() throws PersistenceException
Initialize the EntityManagerFactory for the given configuration.- 指定者:
createNativeEntityManagerFactory在类中AbstractEntityManagerFactoryBean- 返回:
- EntityManagerFactory instance returned by this FactoryBean
- 抛出:
PersistenceException- in case of JPA initialization errors