I am using JBoss 4.0.5GA.
Student and Course: many to many relation.
class Student {
@ManyToMany(fetch = FetchType.LAZY,
targetEntity = Course.class)
@JoinTable(name = "Student_Course",
joinColumns = {@JoinColumn(name = "studentId")},
inverseJoinColumns = {@JoinColumn(name = "courseId")})
public List<Course> getCourses() {
return courses;
}
public void setCourses(List<Course> courses) {
this.courses = courses;
}
....
}
Two courses and one student object are created in persistence successfully. Then the two students are added into the Student,
student.setCourses(..)
Student s = em.merge(student);
after transaction is commited, rows are created in the join table successfully. But the detached object(student) has a collection of courses that is dirty(dirty collection), become not usable.
I tried to change the Lazy fetch to eager, it did not solve the problem.
Thanks for help.
David
|