0 Replies Latest reply on Jan 10, 2007 5:51 AM by Dima Yakovlev

    Failed to lazily initialize a collection of role

    Dima Yakovlev Newbie

      Hi...

      I don't speak English very well, so I apologise for that.

      I have a problem.
      I have made Entity Bean with collection field:

      @Entity
      public class DocumentEntity implements Serializable {
      
       private static final long serialVersionUID = 4842258583854141368L;
      
       private int id;
      
       private List<DocCategoryEntity> docCategories;
      
       @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
       public List<DocCategoryEntity> getDocCategories() {
       return docCategories;
       }
      
       public void setDocCategories(List<DocCategoryEntity> categories) {
       this.docCategories = categories;
       }
      ...
      }
      


      I deployed it on JBoss 4.0.4GA + EJB 3.0 RC8 FD.

      After that I made a junit which read a list of DocumentEntity-s (of course, I coded and deployd session bean which provide requered operations).

      And my problem is: when I try to read docCategories field of any item of result list I get an exception "org.hibernate.LazyInitializationException"

      But as you can see in my entity class source I am not using lazy loading (FetchType.EAGER). What did I make wrong???


      Help, PLEASE!!!