Implement SessionFactoryImplementor in SF proxies
SessionFactoryBuilderSupport implementations create DisposableBean proxies for SessionFactory objects created using #buildSessionFactory. Prior to this change, these proxies create problems when working agaist SessionFactoryUtils.getDataSource(SessionFactory), because this method expects the given SessionFactory to implement Hibernate's SessionFactoryImplementor interface (which the stock SessionFactoryImpl does). With this change, the DisposableBean proxies created by SFBuilders now also implement SessionFactoryImplementor to satisfy this and probably other such cases. Issue: SPR-8469
This commit is contained in:
@@ -33,6 +33,7 @@ import org.hibernate.SessionFactory;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
import org.hibernate.classic.Session;
|
||||
import org.hibernate.engine.SessionFactoryImplementor;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
@@ -131,10 +132,11 @@ public class HibernateSessionFactoryConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void builtSessionFactoryIsDisposableBeanProxy() {
|
||||
public void builtSessionFactoryIsProxyImplementingDisposableBeanAndSessionFactoryImplementor() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(AnnotationSessionFactoryConfig.class);
|
||||
SessionFactory sessionFactory = ctx.getBean(SessionFactory.class);
|
||||
assertThat(sessionFactory, instanceOf(DisposableBean.class));
|
||||
assertThat(sessionFactory, instanceOf(SessionFactoryImplementor.class));
|
||||
assertThat(sessionFactory.toString(), startsWith("DisposableBean proxy for SessionFactory"));
|
||||
ctx.close();
|
||||
assertTrue("SessionFactory was not closed as expected", sessionFactory.isClosed());
|
||||
|
||||
Reference in New Issue
Block a user