1 Reply Latest reply on Aug 1, 2006 4:45 AM by Juergen Zimmermann

    oneToMany returning duplicated objects.

    Ezequiel Block Newbie

      Hi to all,

      I have this on Employees's class


      /**
      *
      * @return Collection
      */
      @OneToMany(
      cascade = {CascadeType.PERSIST, CascadeType.MERGE},
      fetch = FetchType.LAZY,
      mappedBy = "owner"
      )
      public Collection getUploadedFiles() {
      return uploadedFiles;
      }


      I have these on UploadedFile's class


      /**
      *
      * @return Employee
      */
      @ManyToOne
      @JoinColumn(name = "EMPLOYEE_ID")
      public Employee getOwner() {
      return owner;
      }

      /**
      *
      * @return Collection
      */
      @OneToMany(
      cascade = {CascadeType.ALL},
      fetch = FetchType.LAZY,
      mappedBy = "uploadedFile"
      )
      public Collection getEmployeesAccess() {
      return employeesAccess;
      }

      and this on UploadedFileEmployeeAccess's class


      /**
      *
      * @return UploadedFile
      */

      @ManyToOne
      @JoinColumn(name = "UPLOADED_FILE_ID")
      public UploadedFile getUploadedFile() {
      return uploadedFile;
      }

      /**
      *
      * @return Employee
      */
      @ManyToOne
      @JoinColumn(name = "EMPLOYEE_ID")
      public Employee getEmployee() {
      return employee;
      }


      for each N UploadedFileEmployeeAccess added to the UploadedFile object there is N duplicated object retrieved in Employee's getUploadedFiles() method.

      Does any know what could be happening?

      Thanks in advance.
      Ezequiel.