nhibernate-core icon indicating copy to clipboard operation
nhibernate-core copied to clipboard

NH-2515 - Enable on-delete="cascade" for <element> and <composite-element>

Open nhibernate-bot opened this issue 8 years ago • 2 comments

Mattias Öhrn created an issue — :

Currently it is not possible to add the on-delete="cascade" attribute to the <key> element of a collection mapping with <element> or <composite-element>. Doing so leads to an exception with the message 'only inverse one-to-many associations may use on-delete="cascade: <entity type>"'.

One reason to enable this is that currently HQL deletes against an entity with an element (or composite element) collection will fail due to a foreign key constraint violation assuming that the collection is non-empty and that the database schema has been created with the hbm2ddl tool.

Another reason might be that ISession.Delete could be more efficient in this case by relying on the database for deleting the collection items.


Mattias Öhrn added a comment — :

Sorry about the ugly title and description - I thought I had to use entity encoding for special characters and now I can't find a way to change it. So if a nice admin sees this, please clean it up.

nhibernate-bot avatar Oct 12 '17 12:10 nhibernate-bot

I'm not the one to 'bump' issues, but I'd really really really love it you could look at this one, please.

igitur avatar Jun 06 '23 14:06 igitur

hibernate commit that removes exception https://github.com/hibernate/hibernate-orm/commit/7c2a58861341f1404b4974f1ed9809f40c1da8f6 (though not sure if it really fixes reported issue)

bahusoid avatar Jun 06 '23 15:06 bahusoid