title: Get entity JPA Id after merge?
body: <p>I have a freshly created entity (detached because not yet saved in the DB). This entity holds another entity that already exists in the db (but is detached, too). Thus, I would use <code>em.merge(myNewEntity)</code> to store it.</p>
  
  <p>If I want to get the new created ID, I would use <code>em.flush()</code> afterwards. Then I invoke <code>myNewEntity.getId()</code>. With <code>persist</code> I receive an ID generted by the DB/JPA. With <code>merge</code>, it does not. The ID in the object remains <code>null</code>. Why is that?</p>