title: Why is data in table updating to null due to the following Java code?
body: <p>The following method is supposed to update a row in a table by updating an object.</p>
  
  <pre><code>public void saveOrUpdate(final T data) throws CPDPersistenceException {
     final EntityManager em = getEntityManager();
     try {
        final EntityTransaction transaction = em.getTransaction();
        transaction.begin();
        em.merge(data);
        transaction.commit();
     }
  } catch (final PersistenceException e) {
     throw new CPDPersistenceException(e);
  }
  </code></pre>
  
  <p>The updated object "data" passed to saveorUpdate() has the new data in it. After the transaction.commit(), though, data is updated in the table but there is one element of the Object - The ID - that is still OK in the table I am updating, but in another table it has been changed to null. Does anybody know how this might happen? Thanks for your time. </p>