Class springBeanContainer
java.lang.Object
org.springframework.orm.jpa.hibernate.springBeanContainer
- All Implemented Interfaces:
BeanContainer, Stoppable
spring's implementation of Hibernate's
BeanContainer SPI,
delegating to a spring ConfigurableListableBeanFactory.
Auto-configured by LocalSessionFactoryBean.setBeanFactory(BeanFactory),
programmatically supported via LocalSessionFactoryBuilder.setBeanContainer(ConfigurableListableBeanFactory),
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.jpa.hibernate.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.- Since:
- 7.0
- Author:
- Juergen Hoeller, Yanming Zhou
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface BeanContainer
BeanContainer.LifecycleOptions -
Constructor Summary
ConstructorsConstructorDescriptionspringBeanContainer(ConfigurableListableBeanFactory beanFactory) Instantiate a new springBeanContainer for the given bean factory. -
Method Summary
Modifier and TypeMethodDescription<B> ContainedBean<B> getBean(Class<B> beanType, BeanContainer.LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) <B> ContainedBean<B> getBean(String name, Class<B> beanType, BeanContainer.LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) voidstop()
-
Constructor Details
-
springBeanContainer
Instantiate a new springBeanContainer for the given bean factory.- Parameters:
beanFactory- the spring bean factory to delegate to
-
-
Method Details
-
getBean
public <B> ContainedBean<B> getBean(Class<B> beanType, BeanContainer.LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) - Specified by:
getBeanin interfaceBeanContainer
-
getBean
public <B> ContainedBean<B> getBean(String name, Class<B> beanType, BeanContainer.LifecycleOptions lifecycleOptions, BeanInstanceProducer fallbackProducer) - Specified by:
getBeanin interfaceBeanContainer
-
stop
-