From 7903d6489f9c98532826324b0ba79cafbc618d78 Mon Sep 17 00:00:00 2001 From: Chris Beams Date: Sat, 30 Jul 2011 18:05:34 +0000 Subject: [PATCH] Auto-unwrap SessionFactoryBuilder-created proxies SessionFactory proxies created by (Annotation)SessionFactoryBuilder now implement InfrastructureProxy to ensure they are automatically unwrapped for transaction resource management purposes. Issue: SPR-8492 git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@4823 50f2f4bb-b051-0410-bef5-90022cba6387 --- .../HibernateSessionFactoryConfigurationTests.java | 2 ++ .../orm/hibernate3/SessionFactoryBuilderSupport.java | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/org.springframework.integration-tests/src/test/java/org/springframework/orm/hibernate3/HibernateSessionFactoryConfigurationTests.java b/org.springframework.integration-tests/src/test/java/org/springframework/orm/hibernate3/HibernateSessionFactoryConfigurationTests.java index 3f9df777ad..0c17a80b2d 100644 --- a/org.springframework.integration-tests/src/test/java/org/springframework/orm/hibernate3/HibernateSessionFactoryConfigurationTests.java +++ b/org.springframework.integration-tests/src/test/java/org/springframework/orm/hibernate3/HibernateSessionFactoryConfigurationTests.java @@ -42,6 +42,7 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; +import org.springframework.core.InfrastructureProxy; import org.springframework.dao.DataAccessException; import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor; import org.springframework.dao.support.PersistenceExceptionTranslator; @@ -137,6 +138,7 @@ public class HibernateSessionFactoryConfigurationTests { SessionFactory sessionFactory = ctx.getBean(SessionFactory.class); assertThat(sessionFactory, instanceOf(DisposableBean.class)); assertThat(sessionFactory, instanceOf(SessionFactoryImplementor.class)); + assertThat(sessionFactory, instanceOf(InfrastructureProxy.class)); assertThat(sessionFactory.toString(), startsWith("DisposableBean proxy for SessionFactory")); ctx.close(); assertTrue("SessionFactory was not closed as expected", sessionFactory.isClosed()); diff --git a/org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/SessionFactoryBuilderSupport.java b/org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/SessionFactoryBuilderSupport.java index 140f9bd8ce..3a9f6a0a3f 100644 --- a/org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/SessionFactoryBuilderSupport.java +++ b/org.springframework.orm/src/main/java/org/springframework/orm/hibernate3/SessionFactoryBuilderSupport.java @@ -52,6 +52,7 @@ import org.hibernate.transaction.JTATransactionFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.DisposableBean; import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.InfrastructureProxy; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import org.springframework.dao.DataAccessException; @@ -566,6 +567,7 @@ public abstract class SessionFactoryBuilderSupport[] { SessionFactory.class, SessionFactoryImplementor.class, + InfrastructureProxy.class, DisposableBean.class }, new InvocationHandler() { @@ -573,6 +575,9 @@ public abstract class SessionFactoryBuilderSupport