1 Reply Latest reply on Jun 24, 2008 2:13 AM by Gary LosHuertos

    Laizy load the Collection

    wilfried deguil Newbie

      Hello,

      I'm using jBoss 4.2.2.GA and EJB3 with JPA.

      I have this entity

      public class Person {

      private Collection geveRoles;
      ...
      ...

      @ManyToMany(mapped="persons")
      public Collection getGeveRoles() {
      return geveRoles;
      }
      }

      and another entity :

      public class GeveRole {
      private Collection persons
      ...
      ...

      @ManyToMany
      @JoinTable(name="EJB_GEVE_PERSONGEVEROLE" , joinColumns = @JoinColumn(name="personId",referencedColumnName="Id"),
      inverseJoinColumn = @JoinColumn(name="geveRoleId",referencedColumnName="Id"))
      public Collection getPerson() {
      return persons;
      }
      }

      So, when in my web application I invoke this :

      RoleList = (List) person.getGeveRoles();

      The jboss console displays :

      failed to lazily initialize a collection of role: fr.horoquartz.core.entity.Person.geveRoles, no session or session was closed

      Thanks in advance for your help
      Please