From ee17afcd33d6572bb6765971d9fc54e26969396d Mon Sep 17 00:00:00 2001 From: Erwin Vervaet Date: Fri, 8 Jun 2007 08:43:22 +0000 Subject: [PATCH] Code review of HibernateSessionPerConversationListener. --- ...HibernateSessionPerConversationListener.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/spring-webflow/src/main/java/org/springframework/webflow/support/persistence/HibernateSessionPerConversationListener.java b/spring-webflow/src/main/java/org/springframework/webflow/support/persistence/HibernateSessionPerConversationListener.java index c0633b0c..ae0ba1a7 100644 --- a/spring-webflow/src/main/java/org/springframework/webflow/support/persistence/HibernateSessionPerConversationListener.java +++ b/spring-webflow/src/main/java/org/springframework/webflow/support/persistence/HibernateSessionPerConversationListener.java @@ -33,18 +33,18 @@ import org.springframework.webflow.execution.ViewSelection; /** * A {@link FlowExecutionListener} that implements the Hibernate - * Session-Per-Conversation pattern as described in Java Persistence with + * Session-per-Conversation pattern as described in Java Persistence with * Hibernate (chapter 11). - * + *

* This implementation uses raw Hibernate APIs and binds the current session to * the thread-local location identified by Spring's * HibernateTransactionManager. - * + *

* This listener assumes that you are accessing Hibernate via Spring support * such as HibernateTemplate or the LocalSessionFactoryBean. If not, Hibernate * data access code will not participate in the proper transaction. - * - * Note that when accessing service layer methods with Spring manged + *

+ * Note that when accessing service layer methods with Spring managed * transactions, those transaction should have {@link Propagation#REQUIRED} * semantics. Anything else defeats the purpose of holding the transaction open * until the end of the session. @@ -58,6 +58,11 @@ public class HibernateSessionPerConversationListener extends FlowExecutionListen private SessionFactory sessionFactory; + /** + * Create a new Session-per-Conversation listener using giving Hibernate session + * factory. + * @param sessionFactory the session factory to use + */ public HibernateSessionPerConversationListener(SessionFactory sessionFactory) { this.sessionFactory = sessionFactory; } @@ -128,6 +133,8 @@ public class HibernateSessionPerConversationListener extends FlowExecutionListen Session hibSession = getHibernateSession(context); unBindSession(hibSession); } + + // internal helpers private Session createSession(RequestContext context) { Session hibSession = sessionFactory.openSession();