Fabio> We've cross-posted, I only saw your question now.
So that we are all on the same page :
class A{
IList<B> myChildren;
}
class B {
}
int Id = 5;
A myEntity = session.getById<A> (Id);
A.myChildren.clear();
session.SaveOrUpdate(A);
If there were 3 children in the collections, the sql generated is:
DELETE FROM TABLE_A WHERE CHILDREN_ID = 1
DELETE FROM TABLE_A WHERE CHILDREN_ID = 2
DELETE FROM TABLE_A WHERE CHILDREN_ID = 3
When what I would like NH to do is :
DELETE FROM TABLE_A WHERE CHILDREN_ID IN (1, 2, 3)
Hope it is clear to everyone now :)
Please someone, tell me NH can do that :)
On 6 avr, 21:11, Graham Bunce <[email protected]> wrote:
> I think you have the same problem I had.... NH will not (as I
> understand it) generate a single DELETE FROM entity WHERE foreignkey =
> X. From my tests it will work out the keys of the child table and
> delete them all one-by-one, i.e. DELETE FROM entity WHERE primarykey =
> Y, where NH has already got the primary keys into its cache.
>
> The documentation is very misleading IMO about this.
>
> On-delete-cascade does not mean NH will do the above, it means NH will
> not do a delete at all and leave it up to the database (RI cascade
> delete or a trigger).
>
> Therefore if you cannot change your DB then you are stuck, which does
> surprise me TBH as there are plenty of brownfield situations where you
> cannot change the DB.
>
> I'm happy for a NH expert to come along and say "no, you're an idiot,
> this is the mapping you need" (and I wish they would) but I've raised
> this query myself on these forums a while ago and this was the
> response I eventually managed to work out from some of the very
> cryptic responses I recieved.
>
> If I'm wrong, then please let me know.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---