title: How to implement row level locking using Hibernate Query Language?
body: <p>Background: I am working on a MYSql database where multiple instances reads from the same Account Table . I want to implement row level exclusive lock using Hibernate Query Language to avoid dirty read.</p>
  
  <p>My code is as below.</p>
  
  <pre><code>List&lt;AccountTableBean&gt; currentRequestslist = sessionFactory.getCurrentSession()
                  .createQuery("from Account where status = :finalStatus")
                  .setLockMode("MappCurrentRequests", LockMode.PESSIMISTIC_READ)
                  .setParameter("finalStatus","Active").list();   
  </code></pre>
  
  <p>Currently, I have used Pessimistic_read on the entire table. Is there a way i can apply to lock on individual rows? Any example will be very helpful.</p>
  
  <p>Thank you,
  Gendaful</p>