Save child objects automatically using JPA Hibernate

前端 未结 7 696
南方客
南方客 2020-11-27 13:13

I have a one-to-many relation between Parent and Child table. In the parent object I have a

List setChildren(List childs)
         


        
7条回答
  •  自闭症患者
    2020-11-27 13:41

    in your setChilds, you might want to try looping thru the list and doing something like

    child.parent = this;
    

    you also should set up the cascade on the parent to the appropriate values.

提交回复
热议问题