How to tell NHibernate that a trigger updates another table?

"YOU AND THE ART OF ONLINE DATING" is the only product on the market that will take you step-by-step through the process of online dating, provide you with the resources to help ensure success. Get it now!

The only work around I've found is shown in the code snippet below using Fluent N It is ugly since it is hard coding SQL into your mapping but it does work. The Check property is set to None so that the counts are ignored. I don't know if you can accomplish this using straight HBM files but there probably is a way.It would be great is there was a configuration option in Nbernate (or Fluent NH) to either set the expected updated row count or ignore it when needed.

The only work around I've found is shown in the code snippet below using Fluent N It is ugly since it is hard coding SQL into your mapping but it does work. The Check property is set to None so that the counts are ignored. I don't know if you can accomplish this using straight HBM files but there probably is a way.It would be great is there was a configuration option in Nbernate (or Fluent NH) to either set the expected updated row count or ignore it when needed.

Public class OrderMap : ClassMap { public OrderMap() { Id(c => c. Id, "order_id").GeneratedBy.Native(); Table("order"); Map(c => c. GroupId, "group_id"); Map(c => c.

Status, "status"); Map(c => c. LocationNumber, "location"); SqlInsert("insert into order (group_id, status, location) values (?,? ,?

)").Check.None(); SqlUpdate("update order set group_id =? , status =? , location =?

Where order_id =? ")).Check.None(); SqlDelete("delete order where order_id =?").Check.None(); } } EDIT: For those unfortunate folks that aren't aware of Fluent Nbernate or love painful generation of HBM files by hand, here is the HBM file for this sample mapping: insert into order (group_id, status, location) values (?,? ,?

) update order set group_id =? , status =? , location =?

Where order_id =? Delete order where order_id =?

I am not using Fluent N do you know where this applies in the N I can't figure out where I should write that (I don't use any ClassMap, nor do I know what it is, and I've not seen functions like SqlInsert or the like). – Carl Jul 6 at 19:00 Please see the edit to my answer. Hopefully, you are not creating the HBMs by hand.

But if are, definitely look at what Fluent Nbernate or the new fluent mapping capability in N0 can do for you. – Sixto Saez Jul 6 at 19:58 Thanks for that. Yes I am creating the HBMs by hand but it isn't a problem for now (I don't find this is particularly difficult).

– Carl Jul 7 at 0:54.

Check with a profiler the sql that gets executed. Anjlab sql profiler always did the trick for me. After that check to see if you have triggers on that table - maybe they are causing some trouble.

EDIT You should alter your trigger like here : codewrecks.com/blog/index.php/2009/03/25....

Thanks for the link. You were right I saw that there is a trigger updating the last_updated_date column of Container (that contains samples) when a sample is updated. Do you know if there is a way to tell N – Carl Jul 5 at 14:13 I think that's what is going to happen, since I've not found any other way to make it work, but since there are 100+ clients using the database with 10+ different applications, I don't know if modifying the trigger can make something stop working in another application.

– Carl Jul 6 at 19:04.

Removed my answer as I didn't read the question sufficiently.

There is nothing you can do to tell Nbernate that a trigger updated an other entity in the database except ignore it like Sixto Saez shows in his answer. However you can use EventListeners to do the trigger action in code. Or set the SET NOCOUNT ON at the beginning of the trigger and a SET NOCOUNT OFF at the end if the update does not matter for the rest of your transaction.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions