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.  [ 8 posts ] 
Author Message
 Post subject: versioning for optimistic locking without locking the DB row
PostPosted: Mon Jan 31, 2005 12:15 pm 
Newbie

Joined: Wed Nov 17, 2004 5:53 am
Posts: 5
Hi,

we are using version for optimistic locking and we don't want any database (ORACLE) lock on the row when a new row is inserted

When we used EJBs, we didn't have lock on the row, now we have a row lock when using Hibernate

Is there an Hibernate configuration to avoid this database row-lock when we're doing an INSERT ?


Best regards,

Fabrice


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 12:49 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
Might be worth looking at the VERY detailed chapter in"Hibernate in Action" about isolation levels and transactions.

By the way, how can you ever have a row lock on a row you are inserting ?

_________________
On the information super B road


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 1:18 pm 
Newbie

Joined: Wed Nov 17, 2004 5:53 am
Posts: 5
Thx for your answer paul,

Quote:
By the way, how can you ever have a row lock on a row you are inserting ?


We are using P6Spy to trace the SQL requests and we have the following sequence :

Thread A inserts row1

Thread B inserts row2

Thread A inserts row2 .....waiting

Thread B inserts row1 .....deadlock


We don't want any waiting lock, when the threadA will try to insert row2, a violation integrity must be raised


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 1:50 pm 
Newbie

Joined: Wed Nov 17, 2004 5:53 am
Posts: 5
Quote:
Might be worth looking at the VERY detailed chapter in"Hibernate in Action" about isolation levels and transactions


I read again this chapter, we are using versionning + read commited , does this strategy prevent me for any row lock from Oracle ?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 5:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I think you are mistaken. INSERTs never block other INSERTs, especially not in read committed.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 31, 2005 6:08 pm 
Senior
Senior

Joined: Tue Aug 03, 2004 2:11 pm
Posts: 142
Location: Somerset
gavin wrote:
I think you are mistaken. INSERTs never block other INSERTs, especially not in read committed.


I have seen scenarios in which the whole file is locked, not in Hibernate but with EJB's. Of course in the normal state of affairs, a locked row on an insert makes no sense at all.

It could be that someone thinks they are using Read Uncomitted, but are actually using another level.

On the iSeries version of DB2 you can find out what isolation level you are actually using by setting the "trace" property to be "true" on the JDBC driver, who knows what the equivalent is on Oracle.

Thinking about it, doesn't Oracle use a file to provide surrogate identity fields ? Maybe that is what is getting locked, as obviously this would be updated whenever an insert takes placce.

It seems to be more of a db than a Hibernate question.

_________________
On the information super B road


Top
 Profile  
 
 Post subject: Modify Oracle lock mode
PostPosted: Tue Feb 01, 2005 1:00 pm 
Newbie

Joined: Wed Nov 17, 2004 5:53 am
Posts: 5
Thx for your answers,

I made some test Weblogic/EntityEjb with its optimistic concurrency and Weblogic/Hibernate, also with its optimistic concurrency

I looked at the system oracle table for locks reporting, V_$lock and i have the following results :

- With Entity Ejb : some DML locks are : LMODE = 2 (Row share)

- With Hibernate : all DML locks are : LMODE = 3 (Exclusive)

Does it mean that Weblo/Entity modifies the default Oracle lock policy ?

Can i do this with Hibernate ?


Fabrice,


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 01, 2005 6:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Check your JDBC transaction isolation level.


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