-->
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.  [ 3 posts ] 
Author Message
 Post subject: Is Hibernate optimistic or pessimistic or both?
PostPosted: Thu Jun 30, 2011 1:59 am 
Newbie

Joined: Thu Jun 30, 2011 1:48 am
Posts: 4
It looks like Hibernate is optimistic by default because optimistic-lock attribute of the <class> element has a default value of version

It looks like Hibernate is pessimistic by default because the docs say that every Hibernate connection to a database will use the database’s default isolation level. However, I can change this by setting hibernate.connection.isolation = 4

Is Hibernate optimistic or pessimistic or both?


Top
 Profile  
 
 Post subject: Re: Is Hibernate optimistic or pessimistic or both?
PostPosted: Thu Jun 30, 2011 4:14 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
you can choose for each entity type if you want to enable optimistic locking by adding a version attribute.

If this version attribute is not used, and you use the lock() API you get a pessimistic lock; if you don't use any, then no locks are used.

Connection isolation doesn't affect optimistic locking, please read http://en.wikipedia.org/wiki/Isolation_ ... systems%29

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Is Hibernate optimistic or pessimistic or both?
PostPosted: Tue Jan 24, 2012 6:02 am 
Newbie

Joined: Fri Mar 03, 2006 6:03 am
Posts: 8
So when you use the version attribute you won't get pessimistic locking even if you use the lock() API?

Thanks.


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