Add an Improvement request to the JIRA: in case of <elements> and <composite-element> we may enable on-delete-cascade.
On Thu, Jan 20, 2011 at 10:08 AM, yhrn <[email protected]> wrote: > Hello, > > I'm trying to get a database level cascade in place for a collection > of strings. > > Consider the following entity class: > > public class MyEntity { > > public int Id { get; set; } > public int SomeIntValue { get; set; } > public IList<string> ListOfValues { get; set; } > } > > The problem is that I cannot find a way to map the collection so that > the foreign key constraint gets the ON DELETE CASCADE option. If I put > on-delete="cascade" on the key element in the mapping I get the > following exception message when building the session factory: 'only > inverse one-to-many associations may use on-delete="cascade"'. > > The reason I want the ON DELETE CASCADE option is so I can execute > bulk delete HQL like : > "delete MyEntity m where m.SomeIntValue = 22". > without getting foreign key constraint violations if ListOfValues is > non empty. > > Also, as far as I understand, NHibernate behaves more efficiently when > using ISession.Delete() to delete an entity if it knows about the > database level cascade, i.e. it leaves it to the database to do the > cascaded deletions. > > So, is there a way of solving this with mappings or do I have to the > add ON DELETE CASCADE myself directly to the DB schema? > > Best regards, > Mattias > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- Fabio Maulo -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
