0

We're using Spring Webflow 2.3 + Primefaces 2.2 + Hibernate on a large project. We'd like to enable always-redirect-on-pause so backbutton and refresh work properly. We'd also like to use lazy OneToMany collection to avoid performance problems.

But we can't make it work together. If we enable both (lazyloading on the collection and redirect-on-pause on the flow) we get a org.hibernate.LazyInitializationException when showing the collection on a primefaces table.

It works fine if we disable the redirect-on-pause so I guess the problem is that the JSF view is rendered after the GET request and the Hibernate session is not reattached. If redirect-on-pause in disabled, the render of the table is done after the first POST request, the hibernate session is there and everything works fine.

If I'm right, this combination (SWF + JSF2 + Hibernate) is never going to work as I expected...

Do your have any similar experience?

3
  • 2
    Are you using OpenSessionInView?
    – Dave Maple
    Jun 16, 2011 at 22:46
  • We're using OpenSessionInView. It works fine when the page is rendered after the POST request. But if I enable always-redirect-on-pause the page is rendered after the GET request and I get the LazyInitializationException. There is a dangerous workaround we're using: we do a hibernate.merge() before rendering the page (<on-render>). It works, but I fear undesirable side effects... Aug 30, 2011 at 12:22
  • See this for the answer: stackoverflow.com/questions/578433/…
    – andreak
    Aug 11, 2012 at 9:16

1 Answer 1

1

You can refer to the chapter 7.2 about "FlowScoped PersistenceContext" of the Spring Web Flow Reference Guide

I hope it's useful for you.

1
  • Although our business logic doesn't fit well with a commit-or-rollback flow, we've tried enabling persistent context as a proof of concept. Unfortunately the problem with the redirect-on-pause and the LazyInitializationException doesn't go away. Aug 30, 2011 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.