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;
}
}
do not eager 2 collections in the same object, esp when you don't use a Set contract.