Reputation: 11
I try to update parent object with deleted child object. It passes successfully, however next load returns deleted object again. It is one to many bidirectional relationship. I am not sure how to deal with update once i have parent object.
Upvotes: 1
Views: 2047
Reputation: 128829
We'll probably need you to provide more details, but typically, one-to-many relationships are mapped with @OneToMany(..., orphanRemoval = true)
and removing a child looks like:
// session opened, transaction begun
Parent p = session.load(Parent.class, 1234);
p.getChildren().remove(child);
// transaction committed, session closed
See the discussion of one-to-many parent/child relationships in the Hibernate reference guide.
Upvotes: 1