Thread:
 MSSQL locking 
 alesj   08 Nov 2004, 13:18 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: alesj (08 Nov 2004, 13:18) Replies: 0, Views: 41169
Subject: MSSQL locking
Does anybody have experience with this:

How do you control locking with Hibernate on MSSQL DB?

Currently I'm using native SQL:

<sql-query name="missingDataQuery">
<return alias="md" class="com.generalynx.ecos.data.MissingData"/>
SELECT {md.*}
FROM missingdata {md}
WITH(rowlock, holdlock)
WHERE {md}.egidasource_id = :sourceId
AND {md}.status = :status
</sql-query>

Is there a way to do this 'object oriented'?
Is there a way to control which hint goes into 'what' clause?

Since I have this problem:
I have scheduled data getting service which starts in n threads. And 
all of these threads are reading/inserting/updating the same table 
(missingdata). No service/thread reads the same data (row) = 
intersection of read collections in each thread is empty.

In each thread I start a transaction, reading short (< 10) list of 
MissingData, making each of them 'dirty' by changing property and 
inserting a few new MissingData.
Before I had problems with updating - so I locked each read row (see 
query). But now I get a deadlock while inserting.

Is there a way to control locking on inserts?

What is to do here?

Thanx, Ales
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]