类 SpringBeanContainer
- java.lang.Object
- org.springframework.orm.hibernate5.SpringBeanContainer
- 所有已实现的接口:
org.hibernate.resource.beans.container.spi.BeanContainer,Stoppable
public final class SpringBeanContainer extends Object implements org.hibernate.resource.beans.container.spi.BeanContainer
Spring's implementation of Hibernate 5.3'sBeanContainerSPI, delegating to a SpringConfigurableListableBeanFactory.Auto-configured by
LocalSessionFactoryBean.setBeanFactory(org.springframework.beans.factory.BeanFactory), programmatically supported viaLocalSessionFactoryBuilder.setBeanContainer(org.springframework.beans.factory.config.ConfigurableListableBeanFactory), and manually configurable through a "hibernate.resource.beans.container" entry in JPA properties, e.g.:<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> ... <property name="jpaPropertyMap"> <map> <entry key="hibernate.resource.beans.container"> <bean class="org.springframework.orm.hibernate5.SpringBeanContainer"/> </entry> </map> </property> </bean>Or in Java-based JPA configuration:LocalContainerEntityManagerFactoryBean emfb = ... emfb.getJpaPropertyMap().put(AvailableSettings.BEAN_CONTAINER, new SpringBeanContainer(beanFactory));
Please note that Spring'sLocalSessionFactoryBeanis an immediate alternative toLocalContainerEntityManagerFactoryBeanfor common JPA purposes: In particular with Hibernate 5.3/5.4, the HibernateSessionFactorywill natively expose the JPAEntityManagerFactoryinterface as well, and HibernateBeanContainerintegration will be registered out of the box.- 从以下版本开始:
- 5.1
- 作者:
- Juergen Hoeller
- 另请参阅:
LocalSessionFactoryBean.setBeanFactory(org.springframework.beans.factory.BeanFactory),LocalSessionFactoryBuilder.setBeanContainer(org.springframework.beans.factory.config.ConfigurableListableBeanFactory),AbstractEntityManagerFactoryBean.setJpaPropertyMap(java.util.Map<java.lang.String, ?>),AvailableSettings.BEAN_CONTAINER
构造器概要
构造器 构造器 说明 SpringBeanContainer(ConfigurableListableBeanFactory beanFactory)Instantiate a new SpringBeanContainer for the given bean factory.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 <B> org.hibernate.resource.beans.container.spi.ContainedBean<B>getBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer)<B> org.hibernate.resource.beans.container.spi.ContainedBean<B>getBean(String name, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer)voidstop()
构造器详细资料
SpringBeanContainer
public SpringBeanContainer(ConfigurableListableBeanFactory beanFactory)
Instantiate a new SpringBeanContainer for the given bean factory.- 参数:
beanFactory- the Spring bean factory to delegate to
方法详细资料
getBean
public <B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer)
- 指定者:
getBean在接口中org.hibernate.resource.beans.container.spi.BeanContainer
getBean
public <B> org.hibernate.resource.beans.container.spi.ContainedBean<B> getBean(String name, Class<B> beanType, org.hibernate.resource.beans.container.spi.BeanContainer.LifecycleOptions lifecycleOptions, org.hibernate.resource.beans.spi.BeanInstanceProducer fallbackProducer)
- 指定者:
getBean在接口中org.hibernate.resource.beans.container.spi.BeanContainer