-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 
Author Message
 Post subject: Locking Issue with SQL Server 2000
PostPosted: Mon Feb 12, 2007 6:10 pm 
Newbie

Joined: Mon Feb 12, 2007 6:00 pm
Posts: 3
Hibernate version: 1.2 Beta 3
Name and version of the database you are using: SQL Server 2000/2005

I am unable to get Pessimistic Locking working under SQL Server 200x. My sample test case does work with PostgresSQL 8.1. Here is my sample case:

Code:
string querySelectById = "SELECT report FROM Api.Report AS report WHERE report.ReportId = :ReportId";
public Report GetById(Guid id)
{
            IQuery query = Session.CreateQuery(querySelectById).SetString("ReportId", id.ToString());
            query.SetLockMode("report", LockMode.Upgrade);
            return query.UniqueResult() as Api.Report;
}


When two threads run through this code, under PostgreSQL the second blocks on UniqueResult (until the first commits), under mssql they both run UniqueResult simultaneously.

What additional information can I provide?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 13, 2007 4:36 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Pessimistic locking is not implemented in the SQL Server dialect.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 13, 2007 11:06 am 
Newbie

Joined: Mon Feb 12, 2007 6:00 pm
Posts: 3
Hi Sergey,

Was this feature left out by design, or is it coming in a future release? If it is a lack of development resources, what effort would be required to adding this feature to the dialect?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 13, 2007 11:23 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
I didn't write the SQL Server dialect so I can only guess that when it was written, NHibernate couldn't accomodate SQL Server syntax of pessimistic locking. If you want to contribute, look at MsSqlServer2000Dialect and implement an override of Dialect.GetForUpdateString and maybe also Dialect.GetForUpdateNowaitString.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 12:03 pm 
Newbie

Joined: Mon Feb 12, 2007 6:00 pm
Posts: 3
Hey Sergey, i've gone ahead and added the locking for 2000/2005. Whom should I send the code changes to for review?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 2:06 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
http://jira.nhibernate.org


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.