What is the use of version number in Hibernate?

Version number is used in optimistic locking in Hibernate. When a transaction modifies an object, it increments its version. Based on version number, second transaction can determine if the object it has read earlier has changed or not.

If the version number at the time of write is different than the version number at the time of read, then we should not commit the transaction.

Leave a Reply

Your email address will not be published. Required fields are marked *