Add on-delete="cascade" support to unidirectional *ToOne relationships.

Description

Currently the on-delete="cascade" option is only available on bi-directional/inverse collections. However, there are some instances where we don't want the collections on the parent side of the relationship, creating a unidirection relationship from child to parent. It would be nice to be able to do something like:

So that child entries are deleted when the parent goes away. Obviously, in this particular example it would be OK to add the collection, but in the actual situation we'd like this in the collection would serve no practical purpose.

It's not critical by any means – we can just tewak the schema by hand and that's fine. But it seems like an easy enough thing to add and would make the schema generation/update tools a little more robust.

Activity

Show:

Vlad Mihalcea June 2, 2016 at 2:24 PM

Applied PR upstream.

Martin Beránek October 7, 2010 at 8:30 AM

This option is available in Annotations, so why not in xml mapping file?

Ivan Garcia February 5, 2008 at 11:30 AM

Hi, I think this feauture it's very important. You can have unidirectional *ToOne relationships wiht on-delete and on-update policcies support. You can add another attribute like on-update, for example you can have:

<class name="Parent">
....
</class>

<class name="Child">
...
<many-to-one name="parent" on-delete="cascade" on-update="cascade"/>
</class>

The cascade possible values can be:

No Action
Cascade
Set Null
Restrict

With the current version of HB we must to have a .sql script to modify this relationships on delete and on update policies.

Fixed

Details

Assignee

Reporter

Components

Fix versions

Priority

Created March 23, 2006 at 12:14 AM
Updated June 30, 2016 at 4:22 PM
Resolved June 2, 2016 at 2:24 PM