When you’ve modeled a parent and child association with a hibernate mapping, you can configure the association so that when you delete a parent all of the children are also deleted. For an example, see these mappings and the test case (method – testCascadedDelete).
In a cascaded delete, first the children get deleted and finally the parent. But the children are deleted one at a time. Instead of say (delete from child where parentId=xx;). I wonder if there is a hibernate setting for optimizing MySQL statements (assuming that a single delete is more efficient than multiple ones).
Advertisement