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?
posted 4 years ago
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