Created NH-3375: https://nhibernate.jira.com/browse/NH-3375

On Monday, January 7, 2013 10:34:26 AM UTC-5, Trinition wrote:
>
> I'm trying to use LockMode to make sure the entity I get through my 
> session locks the row(s) in the database.  However, the generated SQL (for 
> MS SQL Server) appears to only be locking the base row.  This leads to 
> deadlocks when NHibernate eventually updates the properties in the subclass 
> mapping to the child table's row.
>
> I fetch the entity through the session like this:
>
>       CustomerOrder myCustomerOrder = 
> mySession.Get<CustomerOrder>(myCustomerOrderId, LockMode.Upgrade);
>
>  Customer order is a subclass of the Order base class, mapped with 
> table-per-subclass:
>
>       class Order {} // tblOrders
>
>       class CustomerOrder : Order {} // tblCustomerOrders
>
> The generated SQL (observed via NHProf) is:
>
>       SELECT ... 
>
>       FROM   dbo.tblOrders customeror0_ *with (updlock, rowlock)* 
>
>              inner join dbo.tblCustomerOrders customeror0_1_ 
>
>                on customeror0_.OrderID = customeror0_1_.OrderIDID
>
> What I *think* I need is for the "(updlock, rowlock) to also follow 
> tblCustomerOrders (here's one source: 
> http://stackoverflow.com/questions/2577337/can-i-lock-a-record-from-a-join-sql-statment-using-rowlock-updlock
> ).
>
> So if that is what is needed so that the *entity* is locked, shouldn't 
> NHibernate be doing this?
> -- 
> Regards,
> Brian. 
>

-- 
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/-/ZPe74olXSIwJ.
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