Thanks. We had considered writing the delete sql explicitly, but felt NHibernate should be able to do this since it already has the mappings. Otherwise we would have to maintain both the mappings and the delete SQL.
You make a good point that I hadn't realised. NHibernate still loads the entire collection and deletes the items one by one. I had expected NHibernate to do this as a single delete: "DELETE PERSON WHERE COUNTRY_ID = ?". Can NHibernate be setup to do this? Another option is to use database level cascasding deletes. On Feb 19, 1:15 pm, CSharper <[email protected]> wrote: > You usually don't maintain such associations as collections because > you never load them as such. > > Better you just maintain the association as an unidirectional one > pointing from the persons to acountry. And then you provide a service > for deleting acountry. You might want to do the delete operation for > all the persons of acountrywithout NHibernate knowing about it... > e.g. with a stored procedure or a direct database delete command > because even in the delete case you don't want to load all persons of > acountryinto the session, do you? > > On 17 Feb., 15:03, Norman <[email protected]> wrote: > > > > > Lets say I haveCountryand Person objects. > > > I do not want the propertyCountry.Peopleas it would be far too big > > to load. I would always loadpeopleseparately. > > > However I do want to be able to cascade deletes. So if I delete a > >countryI also want to delete itspeople: > > > session.Delete(country); > > > Is there some way to have a mapping without a property or to mark the > > property so that it is never loaded? > > > Thanks for your help.- Hide quoted text - > > - Show quoted text - -- 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.
