Uploaded image for project: 'Spring Web Flow'
  1. Spring Web Flow
  2. SWF-1541

Allow for multiple HibernateFlowExecutionListeners/Hibernate SessionFactories per flow.



      It's probably not a common requirement, but in some rare cases we need to work with two different SessionFactories in a single flow.

      Something like Spring MVCs OpenSessionInViewInterceptor.getParticipateAttributeName() would be nice rather than using HibernateFlowExecutionListener.PERSISTENCE_CONTEXT_ATTRIBUTE .
      OpenSessionInViewInterceptor has the following method which allows for sessions from multiple SessionFactories

      	 * Return the name of the request attribute that identifies that a request is
      	 * already intercepted.
      	 * <p>The default implementation takes the <code>toString()</code> representation
      	 * of the <code>SessionFactory</code> instance and appends {@link #PARTICIPATE_SUFFIX}.
      	protected String getParticipateAttributeName() {
      		return getSessionFactory().toString() + PARTICIPATE_SUFFIX;

      HibernateFlowExecutionListener would look like:

      	private boolean isPersistenceContext(FlowDefinition flow) {
      		return flow.getAttributes().contains(getParticipateAttributeName());
      	private Session getHibernateSession(FlowSession session) {
      		return (Session) session.getScope().get(getParticipateAttributeName());
      	private void setHibernateSession(FlowSession session, Session hibernateSession) {
      		session.getScope().put(getParticipateAttributeName(), hibernateSession);

      As a workaround, for now we use our own HibernateFlowExecutionListener which does exactly this. Alternatively it would be nice if the above private methods were protected to allow for easily overrriding the behaviour of HibernateFlowExecutionListener.




            • Assignee:
              rstoya05-aop Rossen Stoyanchev
              donnchadh Donnchadh O Donnabhain
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: