Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF/Hibernate: How do i manage hibernate sessions in JSF?

 
Jeff Kin
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using JSF/Richfaces and Hibernate. In my hybernate mapping file, i have put
<property name="current_session_context_class">thread</property>
I use getCurrentSession to get the session.

I have a class Order which contains a collection of OrderItem objects. I display a list of Orders in a xhtml page. The aim is that when i select a particular order, it will be displayed in a different xhtml page together with its children (OrderItems). However i get the "LazyInitializationException: Session has been closed" problem.

I am in a dilemma because for my implementation, i am forced to open transactions for everything, e.g. to get the list of Orders, i have to open and commit a transaction. Unfortunately, committing a transaction seems to close the session. How do i make the session to persist through the application session, while at the same time allowing commits to a Database?

Sorry, I am a new to this area.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic