Cascaded delete with hibernate

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

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.