views:

173

answers:

2

I'm trying to clear a collection in a parent/child relationship by either clearing the collection (list.clear()) or creating a new instance of the collection on the parent.

Similar to this: http://markmail.org/message/mnvooa7g57dlbxta#query:+page:1+mid:mnvooa7g57dlbxta+state:results

My test is pretty much identical to the one in the link above. I've tried several combination's of settings but for the life of me I cannot get NHibernate to issues a single sql delete for all of the children as opposed to a sql delete for each child object. I must be missing something.

+1  A: 

Interesting post. Have you tracked ayendes problem within NHibernate Jira?. I tried to and Sergey Koshcheyev marked it as 'not an issue' because of the inverse=true mapping that somehow seems to prohibit one shot delete from working, which means to me the inverse mapping prohibits the delete-orphan from working properly cause the orphans seem to be too self-contained by this. (not sure that this is the right adjective)

Try unidirectional mapping (if possible) from the parent instead to make the childs more dependent and (hopefully) one-shot deletion work.

zoidbeck
Interesting, I never thought about that, maybe one shot deletes only work with a one to many unidirectional association. I'll give it a try and see.
DerekBeattie
I tried a unidirectional association and I get the same results. Maybe it's been removed in 2.12. It's not a big deal, I was just trying to get it to work.
DerekBeattie
A: 

One shot delete could have unintended side effects so I think NHibernate plays it safe and only deletes the children that are cleared from that collection. Of course you could always use hql to write your own delete.

dotjoe
True, I could write hql, I was more curious as to why I couldn't get it to work and if maybe the functionality was removed.
DerekBeattie