title: JPA EclipseLink Adding/Updating entities
body: <p>I'm a bit confused with the way JPA handle adding/updating entities.</p>
  
  <p>ATM, i have this piece of code:</p>
  
  <pre><code>AltContact c = new AltContact("test");
  save(c)
  System.out.println("ENTITY: " + contains(c));
  c.setEnterpriseName("test2");
  save(c);
  System.out.println("ENTITY: " + contains(c));
  </code></pre>
  
  <p>The <em>save</em> method is a simple method on the server side of my application requesting a merge on the EntityManager:</p>
  
  <pre><code>public void save (Object e) {
      em.merge(e);
      em.flush();
  }
  </code></pre>
  
  <p>Where <em>em</em> is an instance of <code>EntityManager</code>.</p>
  
  <p><em>contains</em> is once again a method on server side that will ask the entity manager if a given entity exist in the current persistent context.</p>
  
  <p>The code above create two rows in my table, the first one with the value "test" and the other one with the value "test2", which is not what i want.</p>
  
  <p>I want to create a new row with the value "test" and then, right after the creation of the row, update it and set his value to "test2". I printed out the return of <em>contains</em> after both call to <em>save</em>, <code>false</code> was returned the two times.</p>
  
  <p>I guess the problem come from the fact that my entity is not part of the persistent context after the first call to <em>save</em> so when i call <em>save</em> again, the entity manager consider it's a new entity and create a new row.</p>
  
  <p>How can achieve this updating process?</p>