Deletion of OneToMany unidirectional mapping does not delete all children [message #1258467] |
Thu, 27 February 2014 12:17 |
kon f Messages: 152 Registered: March 2012 |
Senior Member |
|
|
Hey,
I'm trying to delete some children of an entity. Here is my unidirectional OneToMany mapping:
@Entity
public class Student {
//...
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinTable(name="STUDENT_FK", referencedColumnName="ID")
private List<Course> courses;
//...
}
Assume, that courses has a size of 5 and if I perform the following code, the size remains with 4. Only one element is randomly deleted.
// Student is detached!
student.getCourses().clear();
entityManager.merge(student);
entityManager.flush();
Am I doing something wrong? Or is this a bug? If I delete only one element from courses it works as expected.
Thanks.
Kon
[Updated on: Tue, 11 March 2014 10:23] Report message to a moderator
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03023 seconds