title: Java - JPA - @Version annotation
body: <p>How does <code>@Version</code> annotation work in JPA?</p>
  
  <p>I found various answers whose extract is as follows:</p>
  
  <blockquote>
    <p>JPA uses a version field in your entities to detect concurrent modifications to the same datastore record. When the JPA runtime detects an attempt to concurrently modify the same record, it throws an exception to the transaction attempting to commit last.</p>
  </blockquote>
  
  <p>But I am still not sure how it works.</p>
  
  <hr>
  
  <p>Also as from the following lines:</p>
  
  <blockquote>
    <p>You should consider version fields immutable. Changing the field value has undefined results. </p>
  </blockquote>
  
  <p>Does it mean that we should declare our version field as <code>final</code>?</p>