From 34d9fcc050fda3f73fc4ee6299208c8866a9585d Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Thu, 12 Jun 2014 10:45:25 -0400 Subject: [PATCH] Fix issue with Hibernate 3 compatibility Issue: SWF-1637 --- .../persistence/HibernateFlowExecutionListener.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java b/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java index 7b4286c7..446811c1 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/persistence/HibernateFlowExecutionListener.java @@ -89,6 +89,8 @@ public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter private static final Method openSessionWithInterceptorMethod = ReflectionUtils.findMethod(SessionFactory.class, "openSession", Interceptor.class); + private static final Method currentSessionMethod = ClassUtils.getMethod(SessionFactory.class, "getCurrentSession"); + /** * The name of the attribute the flow {@link Session persistence context} is indexed under. @@ -160,7 +162,12 @@ public class HibernateFlowExecutionListener extends FlowExecutionListenerAdapter if (Boolean.TRUE.equals(commitStatus)) { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus status) { - sessionFactory.getCurrentSession(); + if (hibernate3Present) { + ReflectionUtils.invokeMethod(currentSessionMethod, sessionFactory); + } + else { + sessionFactory.getCurrentSession(); + } // nothing to do; a flush will happen on commit automatically as this is a read-write // transaction }