KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am developing an application to help my office track and manage reviews. In the application, I am using JPA 2.0 with Hibernate 3.6.3 as my underlying provider. I am also using spring to inject the persistence context into my DAO. I have built the domain such that there is a Review, a Participant and a Role Entity. The problem I am having is when I get a Review from the Entity Manager there are duplicate copies of the same Participant(i.e. same ID) in the list of participants if the Participant has more than one Role. I have also found the number of duplicates is directly related to the number Roles (i.e. if the a Participant has 3 Roles then the Participant occurs 3 times in the Review's list of participants) I have used straight Hibernate before but this is my first time using JPA so I am sure I have configured something wrong. I just don't know what it is. Here is the code: Review: @Entity public class Review extends BaseModel{ @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER, optional=false) private Item item; @Column(name="ISNEW", nullable=false) private boolean isNew; @Enumerated(EnumType.STRING) @Column(name="STATUS", nullable=false) private ReviewStatus status; @Enumerated(EnumType.STRING) @Column(name="PHASE", nullable=false) private Phase phase; @Enumerated(EnumType.STRING) @Column(name="REVIEW_TYPE", nullable=false) private ReviewType reviewType; @OneToMany( cascade=CascadeType.ALL, fetch=FetchType.EAGER) private List<Participant> participants; @OneToMany(cascade=CascadeType.ALL) private List<Defect> defects; @Column(name="START_DATE", nullable=false) private Date startDate; @Column(name="MEETING_DATE", nullable=false) private Date meetingDate; @Column(name="FINISH_DATE") private Date finishDate; @Column(name="DURATION", nullable=false) private Double duration; public Item getItem() { return item; } public void setItem(Item item) { this.item = item; } public
Tags (comma-separated)
Save Edits
Cancel