hibernate : parent contains a collection of children, when child is deleted/saved I want to automatically "refresh" parent's collections
So if a child is created or deleted, I want to remove/add to collection on parent without manually callin开发者_如何学JAVAg accessing the collection or retreving a new parent object from the session.
Is this possible?
It's of your responsibility to maintain the coherence of the object graph. If you create a child referencing its parent, you should also add this child to the parent's collection. Hibernate won't do it for you.
Thereis no reason to call merge on the parent, though: the goal of merge is to copy the state of a detached entity to its attached versioin, and I don't see what this has to do with your problem.
精彩评论