aspose file tools*
The moose likes Object Relational Mapping and the fly likes Is Hibernate optimistic or pessimistic or both? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Is Hibernate optimistic or pessimistic or both?" Watch "Is Hibernate optimistic or pessimistic or both?" New topic
Author

Is Hibernate optimistic or pessimistic or both?

Mike Okri
Ranch Hand

Joined: Jun 22, 2011
Posts: 83
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?
Ogeh Ikem
Ranch Hand

Joined: May 13, 2002
Posts: 180
Neither is switched on by default. In order to switch on optimistic locking, you have to add a version or timestamp property to every class. Or you can tell Hibernate to perform version checking by inspecting table fields. In order to switch on pessimistic locking, you have to explicitly use one of the LockModes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is Hibernate optimistic or pessimistic or both?