title: concurrency (stale data) problem in JPA
body: <p>Let's say I have methods with following signature</p>
  
  <pre><code>Object getData(int id) {  
    //create a entity manager
    //get data frm db
    //return data
  }
  
  updateData() {
    Object obj = getData(id) 
    //get entity manager
    //start transcation tx
    //update
    //commit tx
  }
  </code></pre>
  
  <p>Now will it cause concurrency issue? Can data be stale in worst case? E.g.
      if I <code>getData</code> and by the time I update, if someone updates the data will my <code>updateData</code> will have stale data?
  Now can i use  following:Will i solve the problem?</p>
  
  <pre><code>Object getData(int id,Entitymanager em) {  
  
        //get data frm db using em
        //return data
      }
  
   updateData() {
        Object obj = getData(id) 
        //get entity manager em
        //start transcation tx
        //getdata using getData(id,em)
        //commit tx
      }
  </code></pre>