We are trying to lock an instance in the database to make sure that is
does not change. But only the inherited class is locked, so we are not
locking the base class.

pseudo code:

class Base { string A { get; set; }}

class Inherited { string B { get; set; }}

Transaction 1:
Inherited myEntity = GetEntity();
session.Lock(myEntity); // doesn't lock Base
if (myEntity.A == "X")
{
  // myEntiy.A can still change during the transaction
}

Transaction 2:
Base myBase = GetEntity();
myBase.A = "X"; // doesn't lock Inherited
Commit;

Transaction 1 locks in the table Inherited, Transaction 2 locks in the
table Base. So they don't wait until the (actually same) entity is
unlocked.

It would be nice if NHibernate would lock the whole hierarchy with
Lock, not only the Inherited. Optionally, by argument or
configuration, it could also lock the whole hierarchy when updating
(this will cause more DB communication, why it needs to be optional).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to