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.
精彩评论