mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-11 01:50:28 +00:00
Retain original requested bean class for SpringContainedBean
Closes GH-36115 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
This commit is contained in:
committed by
Juergen Hoeller
parent
38a397873e
commit
d3a385d222
+16
@@ -33,6 +33,7 @@ import org.springframework.orm.jpa.hibernate.beans.BeanSource;
|
||||
import org.springframework.orm.jpa.hibernate.beans.MultiplePrototypesInSpringContextTestBean;
|
||||
import org.springframework.orm.jpa.hibernate.beans.NoDefinitionInSpringContextTestBean;
|
||||
import org.springframework.orm.jpa.hibernate.beans.SinglePrototypeInSpringContextTestBean;
|
||||
import org.springframework.orm.jpa.hibernate.beans.TestBean;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -42,6 +43,7 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
*
|
||||
* @author Yoann Rodiere
|
||||
* @author Juergen Hoeller
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
extends AbstractEntityManagerFactoryIntegrationTests {
|
||||
@@ -275,6 +277,20 @@ class HibernateNativeEntityManagerFactorySpringBeanContainerIntegrationTests
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRetrieveBeanShouldRetainOriginalBeanType() {
|
||||
BeanContainer beanContainer = getBeanContainer();
|
||||
assertThat(beanContainer).isNotNull();
|
||||
|
||||
ContainedBean<TestBean> bean = beanContainer.getBean(
|
||||
"single", TestBean.class,
|
||||
NativeLifecycleOptions.INSTANCE, IneffectiveBeanInstanceProducer.INSTANCE
|
||||
);
|
||||
|
||||
assertThat(bean).isNotNull();
|
||||
assertThat(bean.getBeanClass()).isSameAs(TestBean.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The lifecycle options mandated by the JPA spec and used as a default in Hibernate ORM.
|
||||
|
||||
Reference in New Issue
Block a user