2 Replies Latest reply on Oct 14, 2005 11:05 AM by thunderbear

    Possible bug with many OneToMany relation...

    sleepycrom

      Have this situation:

      MainEntity
      - subEntitys1 (OneToMany)
      - subEntitys2 (OneToMany)
      - subEntitys3 (OneToMany)

      Code is very simple,

      for MainEntity:

       @OneToMany(mappedBy="employee", cascade=CascadeType.ALL, fetch=FetchType.EAGER)
       public Collection<Education> getEducation() {
       return this.education;
       }


      SubEntitys:
       @ManyToOne(optional=false)
       @JoinColumn(name="cEmployeeID")
       public Employee getEmployee() {
       return this.employee;
       }


      The problem is that the result is a multiply of alle three subEntitys.

      Sample:
       MainEntity have...
       4 subEntitys1 (x=4)
       3 subEntitys2 (y=3)
       5 subEntitys3 (z=5)
      

      Then mainEntity.getSubEntitys1().size=60(x*y*z). This happend when you call getters more than once... Anyone with the same problem ? Will try to create a testcase, but now I use query to make a workaround...