-->
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: Pessimistic locking for SQL Server 2005 in 3.2.4sp1?
PostPosted: Tue Sep 25, 2007 9:44 am 
Newbie

Joined: Tue Jul 24, 2007 1:00 pm
Posts: 2
Does ayone know if pessimistic locking works in Hibernate version 3.2.4 sp1.

I do not see it working for gets for SQL Server 2005. I'm using org.hibernate.dialect.SQLServerDialect in my configuration.

Here is a couple examples of things that I tried to get it working.

Example 1:

bean = ((Session)em.getDelegate()).get(pojo.getClass(),key,LockMode.UPGRADE);

Session is org.hibernate.Session
em is javax.persistence.EntityManager

Example 2:

SQLServerDialect.getDialect().appendLockHint(LockMode.UPGRADE, pojo.getClass().getName());

What I'm trying to have happen is the hint applied to the sql statement

ie. FOR UPDATE

or

WITH (UPDLOCK,ROWLOCK)

I need the row locked while the transaction is opened (T1), which means it cannot be read by another transaction (T2) until the current transaction is commited (T1).

I saw some posts that as of version 3.2.2 this had not been working.

Any help would be greatlty appreciated.

Thanks,

Tim


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 13, 2008 3:40 am 
Newbie

Joined: Thu Oct 06, 2005 5:26 am
Posts: 17
I'm not sure. But I've run a test on our deadlock problem where I modified the Hibernate source to add 'WITH (ROWLOCK)' to our SQL insert, delete and update statements. With clustered indexes on SQL server our deadlocking issues went away.

If this can be done with the standard Hibernate plugin it would help a lot.


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.