Hibernate - One to many relationship and orphanRemoval cascade

北城以北 提交于 2019-12-03 13:28:57

It was an issue in Hibernate and it is now fixed:

http://opensource.atlassian.com/projects/hibernate/browse/HHH-2269

Basically you are violating a constraint. The row in the db that corresponds to the parent doesn't exist, so there is no foreign key relationship that the child can use to refer to the parent. Add a call to saveOrUpdate on the parent before doing do for the child.

(edit) I missed your comment about cascade before the reformatting. My recollection is that cascade doesn't work upstream that way; you would still need to save the parent first.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!