title: Merge with JPA and subclass ID
body: <p>I got two entities like this (second one have a relation with first one) :</p>
  
  <pre><code>@Entity
  @Table(name="FOA_ADRESSE_ICX")
  public class FoaAdresseIcx implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name="ID_ADRESSE", unique=true, nullable=false, precision=5)
      private long idAdresse;
  
      @Column(length=32)
      private String bat;
  
      @Column(name="COD_POSTAL", length=5)
      private String codPostal;
  
      // getters and setters ....
  }
  
  @Entity
  @Table(name="FOA_INFOS_ICX")
  public class FoaInfosIcx implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name="COD_ICX", unique=true, nullable=false, length=8)
      private String codIcx;
  
      @Column(name="DATE_RAFFRAICHISEMENT")
      @Temporal(TemporalType.TIMESTAMP)
      private Date dateRaffraichisement;
  
      @Column(name="LIB_AGENCE", nullable=false, length=98)
      private String libAgence;
  
      //uni-directional many-to-one association to FoaAdresseIcx
      @ManyToOne
      @JoinColumn(name="ID_ADRESSE", nullable=false)
      private FoaAdresseIcx foaAdresseIcx;
  
      // getters and setters....
  }
  </code></pre>
  
  <p>I got a problem with the merge :</p>
  
  <pre><code>myEntityMgr.merge(myFoaInfosIcx);
  </code></pre>
  
  <p>Got this exception :</p>
  
  <pre><code>GRAVE: EJB Exception: : javax.persistence.EntityNotFoundException: Unable to find com.groupama.middlgan.entities.FoaAdresseIcx with id 0
  </code></pre>
  
  <p>In <code>myFoaInfosIcx</code> id is 0 because I don't initialise it, because I want JPA to create new FoaAdresseIcx in database if doesn't exist.</p>
  
  <p>How can I do that ?</p>