Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-5474

@PostLoad -> LazyInitializationException: illegal access to loading collection ond a @OneToMany with FetchType.EAGER

    XMLWordPrintable

Details

    • Bug
    • Resolution: Obsolete
    • Major
    • No Release
    • JBossAS-4.2.2.GA
    • EJB
    • None

    Description

      I have a bean with a @OneToMany relation mapping like

      private List<TherapieeinheitBean> therapieeinheiten;

      @OneToMany(
      cascade =

      {CascadeType.REFRESH}

      ,
      fetch = FetchType.EAGER,
      mappedBy="therapiekatalog"
      )

      with FetchType.EAGER and a simnple @PostLoad like

      @PostLoad
      public void postLoad()

      { System.out.println("!!!!!!!!!! postLoad !!!!!!!!!!"); System.out.print("size: " + therapieeinheiten.size()); }

      When an entity of this bean is loaded JBoss trows

      org.hibernate.LazyInitializationException: illegal access to loading collection
      at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:341)
      at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
      at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:249)
      at de.visiodesk.therapiekatalog.TherapiekatalogBean.postLoad(TherapiekatalogBean.java:170)
      .
      .
      .

      and prints the messages

      WARN [LoadContexts] fail-safe cleanup (collections) : org.hibernate.engine.loading.CollectionLoadContext@2c8ce9<rs=Ingres-ResultSet[18523]>
      WARN [CollectionLoadContext] On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [206] entries

      afterwards. The PostLoad method should be called after the data was completely loaded. Is there a workaround for this Problem? I found some other ressources on the net where peole had the same problem, but I saw no resolution, no hint, no workaround.

      Attachments

        1. Child.java
          0.5 kB
        2. Parent.java
          1 kB
        3. PostLoadTest.java
          1 kB

        Activity

          People

            rhn-engineering-ebernard Emmanuel Bernard
            lindner-1 Stefan Lindner (Inactive)
            Votes:
            24 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: