title: how to handle optimistic locking exception in jpa
body: <p>What is most suitable way to handle optimistic locking in jpa. I have below solutions but don't know its better to use this.</p>
  
  <ol>
  <li>Handling exception of optimistic locking in catch blocking and retrying again.</li>
  <li>Using Atomic variable flag and checking if its processing then wait until other thread finish its processing. This way data modification or locking contention may be avoided.</li>
  <li>Maintaining queue of all incoming database change request and processing it one by one.</li>
  </ol>
  
  <p>Anyone please suggest me if there is better solution to this problem. </p>