Which type of locking mechanism use in hibernate ?

We can implement two types of locking mechanism in Hibernate as follows


1. Optimistic Lock:---
                             when transaction acquires  the Optimistic lock on a column or row then other transaction can read the locked column or row data but can't update the data.


2.  Pessimistic Lock:---
                           when transaction acquires the Pessimistic lock on a column or row then other transaction can't read or update data.


Hibernate  prefer optimistic locking for better concurrency. Default value is true.
when Hibernate decide to lock then optimistic make false.
<optimistic-lock="false">


Possible values are:

  •  none
  • version
  • dirty
  • all



Default value is version


<class name="" table="" optimistic-lock="version">




-----
<set name=""  optimistic-lock="false">
----


</set>


</class>








  

0 comments :

Post a Comment