Instruct NHibernate how NOT to delete base class record #2565
Replies: 7 comments
-
@mwpowellhtx take a look at this SO question. I think you should let ORM do its work. |
Beta Was this translation helpful? Give feedback.
-
@chester89 It's not the same question that I'm asking here. Of course, if Child Record gets deleted, Parent Record should be as well. I want for the database to handle its bookkeeping, as I mentioned, and for the ORM, apparently, to be instructed to respect that decision as well. |
Beta Was this translation helpful? Give feedback.
-
Then I guess it's a question to NHibernate folks. If NH allows this, then Sent with MailTrack 2016-09-05 17:33 GMT+03:00 Michael Powell [email protected]:
Yours faithfully, |
Beta Was this translation helpful? Give feedback.
-
Thanks, I figured as much. I posted on the NHibernate Dev list (Google) along these lines. For now, I've backed out the triggers. |
Beta Was this translation helpful? Give feedback.
-
Can you provide a link to the mailing list thread? Sent with MailTrack 2016-09-05 18:17 GMT+03:00 Michael Powell [email protected]:
Yours faithfully, |
Beta Was this translation helpful? Give feedback.
-
Sure thing. I posted this morning, possibly being "moderated"? I don't know. If/when I see the post, or re-post, will follow up here. In the meantime, I'm "happy" to report that "it works" when I let the ORM handle things. However, this is as presently expected, as SQL Server Profiler revealed to me earlier. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Forever immortalized. Well, for consideration at any rate. |
Beta Was this translation helpful? Give feedback.
-
I made a design decision in my database to delete a base class table record via after delete trigger on the child class table record. However, what I am finding is that NHibernate first deletes the child record, which is correct, but then also deletes, or attempts to delete, the now-deleted base class record.
At minimum I need to somehow instruct, perhaps via the
Extends<BaseClass>()
call, however, such a mechanism does not presently exist it seems.I may do something with
SqlDelete()
, provided that would potentially bypass the multiple delete SQL statements being generated, as a workaround.Worst case I remove the after delete trigger statement(s), but I am loathe to do something like that in this instance because the model integrity is maintained through the database as much as possible.
Open to suggestions, first of all, or potentially does this require some work in either Fluent and/or NHibernate itself?
Beta Was this translation helpful? Give feedback.
All reactions