It could be that I completely misunderstood how the feature works. However, I am confused as a call to Session.Lock with LockMode.Force does not seem to have any effect when using SQLServer CE.
The issue that I am trying to resolve is as follows: I have an application that uses multiple threads to insert and update data using NHibernate and SQL Server CE. I am getting deadlock issues, because: - thread #1 creates new entries for table ORDER and its children ORDERITEM - thread #2 updates ORDERITEM status and sometimes ORDER status (when all are finished) Apparently, NHibernate generates the following SQL sequence - thread #1: insert into ORDER, then insert into ORDERITEM - thread #2: update ORDERITEM, then update ORDER This is causing deadlocks with thread #1 holding a lock on ORDER waiting for a lock on ORDERITEM and thread #2 the other way round. Unfortunately, SQL Server CE has no way of preventing index PAGE locks, so the threads will conflict, even if they do not access the same rows. I have entertained two options: - force thread #2 to update ORDER first, then ORDERITEM => I have no idea how to accomplish this. The order in which the properties are set on the in-memory objects does not seem to have any effect - force thread #2 to aquire a lock on ORDER first, then do its work => this is where I was hoping for Session.Lock() with LockMode.Force. However, other than expected, I do not see any SQL statement being issued at all and the deadlocks still occur. Have I misunderstood the feature, or is there another option to consider? J.- -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/CH8U5loAe-cJ. 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.
