-->
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.  [ 9 posts ] 
Author Message
 Post subject: Is row level locking available in hibernate?
PostPosted: Mon Apr 05, 2004 5:48 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Hi

Is row level locking available in hibernate?

Thanks
Yogs


Top
 Profile  
 
 Post subject: Re: Is row level locking available in hibernate?
PostPosted: Mon Apr 05, 2004 6:43 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
Yogs wrote:
Hi

Is row level locking available in hibernate?

Thanks
Yogs


I don't think row level locking is native to hibernate. However, you might want to check out the following section in regards to versioning and locking.

http://www.hibernate.org/hib_docs/reference/html/transactions.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 12:32 am 
Regular
Regular

Joined: Fri Sep 05, 2003 12:01 am
Posts: 80
Location: Bogot
you can lock an object:

Code:
session.lock (myObject,LockMode.SOME_MODE)


Refer to the api for LockMode.

As for my Object it can be either a transient or persistent object[/code]

_________________
Mauricio Hern


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 7:57 am 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
But does locking a session as you have suggested have the same effect as a true row level locking? After all, sessions aren't threadsafe.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 7:58 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Both concepts are not related. If you use an exclusive LockMode, the database will have an exclusive lock, as Hibernate never locks in memory. A concurrent Session will either have to wait or immediately throw a SQL lock exception.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 11:49 am 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Hi

Thanks for your information. Then when we are using session.saveOrUpdate(object), does that mean that concurrent session calling session2.saveOrUpdate(object) i.e. for the same object will overlap with first one?

Thanks
Yogs


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 11:50 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, usually you have optimistic concurrency with version checks. There is even a chapter about all this in the reference documentation, please read it.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 12:25 pm 
Senior
Senior

Joined: Wed Mar 24, 2004 11:40 am
Posts: 146
Location: Indianapolis, IN, USA
christian wrote:
No, usually you have optimistic concurrency with version checks. There is even a chapter about all this in the reference documentation, please read it.


I think that is the link I posted earlier in the thread. For implicit row level locking I am considering the use of a ProcessLock table that keeps a record of processes that are locked and the lock is removed once the processing is completed.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2004 12:34 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is a bottleneck. You should first have a good overview on optimistic and pessimistic locking, search Google for those keywords.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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