I have a small problem in my use of wonderful nHibernate 1.2 against MSSQL 2005 :-)
I have searched the forum and the net and found the only usefull answer to implement this logic using SQL/Stored procedures.
I have an application where users can "tag" items, so the database structure is:
Item *---1 TagItems 1---* Tag
And in my model i have a collection of tags on an Item and a collection of Items on a Tag
Now i need to remove an tag from an item and still keep both entities in the database, in other words i want to delete from the TagItems table.
The only solution i found was using:
Code:
myItem.Tags.Remove(myTag);
myTag.Items.Remove(myItem);
mySession.SaveOrUpdate(myItem); //with cascade save-update on item
However i would like to avoid fetching all the data to do this "simple" operation, but specifying a query for the Delete method on ISession isn't possible as i am not deleting a mapped entitiy(if it is please enlighten me).
The other thing i tried to explore is specifying a delete cascade, but this seems like a bad idea when dealing with at many-to-many relation as no cascadestyle looks like they preserve both entities when the association is removed from one side.
As i sidenote is it possible to implement a custom cascade, and is this in anyway "plugable"/configurable or should i compile my own nhibernate version?
Any help is appreciated, even if its just a confirmation that i have to implement it using a custom SQL/Stored procedure