Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

Jeff Kin
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
Boost this thread!