public final class SpringBeanContainer extends Object implements BeanContainer
Spring's implementation of Hibernate's BeanContainer SPI, delegating to a Spring ConfigurableListableBeanFactory.
Auto-configured by LocalSessionFactoryBean.setBeanFactory, programmatically supported via LocalSessionFactoryBuilder.setBeanContainer, and manually configurable through a "hibernate.resource.beans.container" entry in JPA properties, for example:
<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's LocalSessionFactoryBean is an immediate alternative to LocalContainerEntityManagerFactoryBean for common JPA purposes: The Hibernate
SessionFactory will natively expose the JPA
EntityManagerFactory interface as well, and Hibernate BeanContainer
integration will be registered out of the box.
| Constructor and description |
|---|
SpringBeanContainer(ConfigurableListableBeanFactory beanFactory)Instantiate a new SpringBeanContainer for the given bean factory. |
| Type Params | Return Type | Name and description |
|---|---|---|
<B> |
public ContainedBean<B> |
getBean(Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) |
<B> |
public ContainedBean<B> |
getBean(String name, Class<B> beanType, LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) |
|
public void |
stop() |
Instantiate a new SpringBeanContainer for the given bean factory.
beanFactory - the Spring bean factory to delegate to