title: Hibernate merge and flush do not persist changes to an object
body: <p>This is a Hibernate/JPA question around updating an object in the database.  </p>
  
  <p>I have an object that I created in another transaction using entityManager.persist(object).</p>
  
  <p>This object is returned and then some values are updated.  A call then is made in another method that is annotated with @Transactional.  This method calls a merge method in a base class (shown below).  </p>
  
  <p>In the following code, rvalue has the modified information up until refresh is called.  Once refresh is called, the data is back to the original values.  </p>
  
  <p>I would expect that the call to flush() would persist the information to the database. </p>
  
  <p>I tried commenting out the refresh call, thinking the save does not happen until I leave the method wrapped in transactional.  However, I am still finding the changes are not being persisted.</p>
  
  <p>Any ideas on what may be happening would be greatly appreciated! </p>
  
  <pre><code>@Override
  public T merge(T object) {
      T rvalue = entityManager.merge(object);
      entityManager.flush();
      entityManager.refresh(rvalue);
      return rvalue;
  }
  </code></pre>