1 Reply Latest reply on Mar 15, 2006 4:20 PM by antonio gonzalez

    org.hibernate.LazyInitializationException

    Rajesh Patel Newbie

      Hello,

      I have a process definition that has a fork in it. I save the process instance at each stage (after signalng at each node). When I retrieve it from the database and try to obtain it's child token (well, really root token's children), I get the following exception:

      Exception in thread "main" org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: org.jbpm.graph.exe.Token.children, no session or session was closed
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
       at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
       at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:97)
       at org.hibernate.collection.PersistentMap.isEmpty(PersistentMap.java:102)
      ..
      ..
      ..
      


      Any idea.

      Thanks
      Raj


        • 1. Re: org.hibernate.LazyInitializationException
          antonio gonzalez Newbie

          i cant tell from the snippet of stacktrace you left for sure but it seems that hibernate is fetching a shallow object without initializing the collections within.. as for how to make it initialize that collection before throwing the exception if you're using ejbql you'll want to use the fetch keyword to initialize collections or you'll want to explicitly call (thereby properly populating) each member of your collection before the hibernate transaction closes.

          hope this helps