[jboss-user] [EJB 3.0] - oneToMany returning duplicated objects.

ezequielb do-not-reply at jboss.com
Mon Jul 31 14:05:27 EDT 2006


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.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961967#3961967

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961967



More information about the jboss-user mailing list