开发者

hibernate : parent contains a collection of children, when child is deleted/saved I want to automatically "refresh" parent's collections

开发者 https://www.devze.com 2023-04-12 00:30 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号