Using JSF/Richfaces and Hibernate. In my hybernate mapping file, i have put
Quote:
<property name="current_session_context_class">thread</property>
I use getCurrentSession to get the session.
Code:
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
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?