Hibernate Unidirectional Parent/Child relationship - delete() performs update on child table instead of delete

后端 未结 2 822
余生分开走
余生分开走 2020-12-16 03:47

If I delete a record from the Parent table I want the corresponding records in the child table to be deleted. How can I make Hibernate delete from the Child tabl

2条回答
  •  爱一瞬间的悲伤
    2020-12-16 04:15

    I encountered this error all the time.

    Just put an inverse="true" on the relationship and your problem will go away!

    
            
            
            
        
    

    Basically the inverse will tell hibernate the child cannot exist without a parent, thereby causing hibernate to delete the child.

    Having said that, you'll also need to remove the charityTransfer object from the collection in the parent as well.

提交回复
热议问题