0 Replies Latest reply on Dec 27, 2005 4:28 PM by rfboehme

    Problems Lazy loading in Hibernate Server Side

    rfboehme

      Hi there. I'm using Hibernate with Spring and JBoss, and am having problems with lazy loading. I'm using XDoclet to generate my Hibernate configuration files, and have searched on this topic extensively. The best resource so far that I have found is here:

      http://www.jroller.com/page/kbaum/20040708

      an interesting entry is:

      http://www-128.ibm.com/developerworks/java/library/j-hibern/

      This describes how to implement lazy loading in the business layer. When I implement, however, I still get a LazyLoadingException (config files below):

      @APPNAME@] 23484 ERROR [AWT-EventQueue-0] LazyInitializationException.(25) | Failed to lazily initialize a collection - no session or session was closed
      net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
      at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
      at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
      at net.sf.hibernate.collection.Bag.iterator(Bag.java:256)


      I have also tried using the OpenSessionInViewInterceptor and OpenSessionInViewFilter. However, because data objects are accessed using a manager class which accesses the DAO class, I didn't have high expectations of that method's working.



      In our Hibernate application context, we have:

      <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->





      along with DAO implementation beans, like so:

      <!-- UserDAO: Hibernate implementation -->





      We have a "service" application context, wherein is:















      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED
      PROPAGATION_REQUIRED,readOnly





      //I've tried putting a reference to the hibernateInterceptor here. That doesn't help.







      com.adaptiverfid.service.ShipmentManager



      hibernateInterceptor






      Any help is appreciated.

      Thanks.

      Richard