1 Reply Latest reply on Apr 20, 2008 6:36 PM by virlene

    OpenSessionInViewFilter - lazy loading issue

    VG24
      I am getting LazyInitializationException when I try to load lazy data using Hibernate lazy mapping. I have configured OpenSessionViewInFilter for mxml servlet but it doesn't seem to be working.
      If I use this filter for my custom servlet other than Flex servlet, lazy loading works fine. Am I missing anything?

      Here is my environment.

      Backend - Spring Services(exposed as RMI) , Hibernate and SQL Server- deployed in JBoss as a webapp1.
      Frontend - Spring, Flex, FDS, JBoss - deployed as a web app2.
      - Assembler class(extends AbstractAssembler) for accessing spring services from webapp1.

      Here is the snippet of code.
      web.xml
      <filter>
      <filter-name>hibernateFilter</filter-name>
      <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter- class>
      <init-param>
      <param-name>singleSession</param-name>
      <param-value>true</param-value>
      </init-param>
      </filter>
      <filter-mapping>
      <filter-name>hibernateFilter</filter-name>
      <url-pattern>*.mxml</url-pattern>
      </filter-mapping>

      data-management-config.xml

      <destination id="forms">
      <adapter ref="java-dao" />
      <properties>
      <source>formsAssembler</source>
      <factory>spring</factory>
      <metadata>
      <identity property="formID" type="java.lang.Long"/>
      </metadata>
      <use-transactions>true</use-transactions>
      <cache-items>true</cache-items>
      <auto-sync-enabled>true</auto-sync-enabled>
      </properties>
      </destination>

      Assembler:

      public class FormsAssembler extends AbstractAssembler
      {
      FormService formService;

      public void setFormService(FormService formService)
      {
      this.formService = formService;
      }

      public Collection fill(List fillParameters)
      {
      return formService.getActiveForms();
      }

      -- other methods
      }