1 Reply Latest reply on Dec 30, 2005 7:50 PM by epbernard

    Double entrys in collection

    ckrammer

      Hello,

      I have some problems with OneToMany-Relationships in Entity Beans. When I try to get entries via the corrensponding getter method, the return Collection contains all results twice. I have initalized the Collections as HashSet, why can this happen? Are there some common mistakes I make?

      Christoph

      public class UserDataEntityBean implements Serializable {
       private long id;
       private UserEntityBean user;
       private Date lastupdate;
       private Collection<StudyEntityBean> studies;
      
      ...
      
       public UserDataEntityBean() {
       this.studies = new HashSet<StudyEntityBean>();
       }
      
      ...
      
       @OneToMany(fetch=FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy="userdata")
       public Collection<StudyEntityBean> getStudies() {
       return studies;
       }
      
       public void setStudies(Collection<StudyEntityBean> studies) {
       this.studies = studies;
       }
      }
      


      The method called is "getStudies".