1 Reply Latest reply on Sep 5, 2007 2:58 AM by Christian Bauer

    failed to lazily initialize a collection of role exception

    Samuel Doyle Apprentice

      So I want to use Hibernate 3.2 for my EM in a JEE5 environment. However, I have an entity that has and requires TWO mappings of the following:

      @OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER, mappedBy = "owningILDA")
      


      The FetchType is EAGER. This is not against he spec. and should be allowed by Hibernate but it is not. So if I change one to be LAZY I get this exception:
      Caused by: org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.covaluate.infotek.ilda.ejb.entity.ILDAEntityBean.ilda15MinUpdates, 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.initialize(AbstractPersistentCollection.java:343)
       at org.hibernate.collection.AbstractPersistentCollection.write(AbstractPersistentCollection.java:183)
       at org.hibernate.collection.PersistentBag.add(PersistentBag.java:274)
      


      Is there another way around this besides switching back to TopLink Essentials which doesn't result in this problem?