-->
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.  [ 2 posts ] 
Author Message
 Post subject: Force row level locking for update/delete in MS SQL
PostPosted: Thu Mar 13, 2008 5:59 am 
Newbie

Joined: Thu Oct 06, 2005 5:26 am
Posts: 17
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.2.5

Mapping documents:
n/a

Code between sessionFactory.openSession() and session.close():
n/a

Full stack trace of any exception that occurs:
n/a

Name and version of the database you are using:
MS SQL Server 2005 SP2

The generated SQL (show_sql=true):
n/a

Debug level Hibernate log excerpt:
n/a

I was wondering whether there is a way in Hibernate to force SQL server to use row locks when performing deletes and updates?

We have a problem with deadlocks occurring when large numbers of very short transactions are processing small numbers of rows across a couple of tables. Since the default is to use page locking this can result in deadlocks.

I tested this by modifying the Hibernate source to add 'WITH (ROWLOCK, HOLDLOCK)' to the UPDATE and INSERT SQL. This combined with using clustered indexes fixed the deadlock problem. This is something we have seen before in previous C/C++ applications when using SQL via ODBC.


Top
 Profile  
 
 Post subject: Re: Force row level locking for update/delete in MS SQL
PostPosted: Thu Mar 13, 2008 11:14 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
No, I had the same problem and I did the quite the same thing you did. I skimmed through this forum and it appears that people emphasize a read uncommited isolation level to solve this but to me that's way off.


Farzad-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.