0 Replies Latest reply on Jan 14, 2009 9:07 PM by vasubabu76

    Lazy Initialization Exception when using Conversation Scope and Hibernate Session Factory

    vasubabu76
      My application is based on spring framework and the dao layer is implemented using spring's HibernateDaoSupport class.
      Now we want to introduce Seam in the web tier first to take advantage of its conversation scope.
      I am able to configure the application and had it up and running but I am getting Lazy Initialization exception even when using conversation scope. The persistece is not implemented using JPA but using HibernateDaoSupport class.

      My components.xml looks like this.
      <persistence:hibernate-session-factory name="sessionFactory"/>
      <persistence:managed-hibernate-session name="hibernateSession" session-factory="#{sessionFactory}"/>     
      <spring:spring-transaction platform-transaction-manager="#{springTransactionManager}" join-transaction="true" auto-create="true"/>
                          
         <spring:context-loader

            config-locations ="classpath:spring-cre-web.xml,classpath:spring-cre-security.xml,
            classpath:spring-cre-dao-ehcache.xml/>
      </components>


      @Name("orrAction")
      @Scope(ScopeType.CONVERSATION)
      public class MyAction {
           @In(required = false )
           @Out(required = false, scope=ScopeType.CONVERSATION )     
           private List<Order> orders;
               @Create
               @Begin
               public void init() {
                 orders = //get orders from service layer
               }
               public void selectOrder(int orderId) {
                iterate through orders and get the required order
                order.getItems() /// throws LIE exception
               }
      }

      when I call getItems method in the selectOrder method on a postback, I get Hibernate Lazy Initializtion exception saying no session or closed session.
      I starder to wonder if the persistence context is extended only using JPA type persistence context and not bootstraping the hibernate session factory. Is it true ? Any suggestions are appreciated.


      Thanks in advance.