Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate versioning vs locking

 
Mike Okri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm writing a hibernate application and I'm using hibernates automatic version checking to ensure that my transactions are properly isolated from each other. I'm doing this by adding the version property in all of my classes. Is this enough or do I also need to set an isolation level in my application? For example



I like automatic version checking, because it does not use locks.

I don't like to set an isolation level because it introduces locks.

Is it a good idea to mix optimistic and pessimistic transaction isolation. Or is it overkill?
 
Rishi Shehrawat
Ranch Hand
Posts: 218
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should use either one of them. Given a choice it is better to use Hibernate version because of reasons provided by you.
 
Mike Okri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the docs say that hibernate will use the default isolation level of the database if you don't specify an isolation level.
 
Mike Okri
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess automatic versioning will do and I'll use stricter locking where needed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic