Thanks!
I am using JBoss 4.0.5GA, The CascadeType does not have SAVE_UPDATE or DELETE_ORPHAN.
If I retrieve a list of courses from database and assign them to a student , and then save(merge) the student, all in one transaction, it works fine, no errors.
The issue occurs when I work on detached entities, because of the nature of web application.
Transaction 1: get the student from database
Transaction 2: get all available courses from database
Transaction 3: let user select a number of courses (no db operation)
student.setCourses(selectedCourses);
Transaction 4: merge the student. --- error occurs.
em.merge(student)
Thanks for ideas.
gurpreet wrote:
Hi ,
What i can think of without the code is that maybe you missed the cascade option in the student class.
Try this with your collection
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN})