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 |