title: JPA How can I get the generated id/object when using merge from parent but child is created?
body: <p>I have an entity that has been previously persited and has a <code>@OneToMany</code> relationship with another entity. In order to add a new entity I just add my new entity in the managed object and use <code>cascadeType.ALL</code> to persist the changes. Is there a way that I can get the id's of the newly created objects or get the original (unmanaged) object I used with the merge to have its id updated?</p>
  
  <p>In pseudo-code I would expect the following to happen:</p>
  
  <ol>
  <li>New copy is going to be returned for merged entity</li>
  <li>Old copy is going to be update for new entities</li>
  </ol>
  
  <p>Example:
  Parent A, id=13
  Child B, id=0</p>
  
  <p>In essence, I want to issue a <code>merge</code> on the parent but cascade <code>persist</code> on child (so that the original child instance is updated, not copied).</p>
  
  <p>Obviously this doesn't happen. 
  I am using hibernate as the provider.</p>