We have two methods, Find (Get) and FIndForUpdate (QueryOver).
If one process does a FindForUpdate to lock a row, and another uses
FindForUpdate to query that same row. The second process pulls out the old
modified data. I expected it to be locked out by the first.
Process 1.
var user = Repository.FindForUpdate<User>(id);
//change ExternalSubscriptionId to 222222
// delay (10000)
// end
Process 2
var user = Repository.Find<User>().SingleOrDefault(x =>
x.ExternalSubscriptionId == "111111");
//shouldn't be able to find this user as the id has changed
above and should have been locked our until the transaction was complete.
Looking at the database profiler, the select query for process 2 actually
runs first!
Any idea why this is happening.
public T Find<T>(object id, bool cacheable = false) where T :
class, IIdentifiable
{
return !cacheable
? Session.Get<T>(id)
: Session.QueryOver<T>().Where(x => x.Id ==
id).Cacheable().SingleOrDefault();
}
public T FindForUpdate<T>(object id) where T : class, IIdentifiable
{
return Session.Get<T>(id, LockMode.Upgrade);
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.