开发者

Why does lazy loaded child object not get deleted for detached parent object

I have a doubt about how JPA handles lazy initialization of child objects.If i have object A conta开发者_开发知识库ining a one-to-many with object B ( where B is lazy initialized) and i load object A( without accessing Set(B)) so that the Set(B) is null. Now if i detach A and then later merge(A), then why does JPA (in my case implemented by Hibernate) not delete the records for Set(B), given that Set(B) is now null? I have cascade=ALL set on Set(B).

I apologies if this is a trivial question or my understanding of the topic is not clear.


cascade=ALL isn't enough. You also need to delete orphans.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜