title: JPA @OneToMany with @EmbeddedId
body: <p>I have the following Class (Parent):</p>
  
  <pre><code>@Entity
  @Table(name = "PROBE_CUSTOMERS")
  public class ProbeCustomer implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private long id;
      private String name;
      private String hostname;
      private List&lt;ProbeMonitor&gt; monitors;
  
      ....
      @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true)
      @JoinTable(name = "Probe_Monitors", 
              joinColumns = {@JoinColumn(name = "Df_Customer")})
      @XmlElement(name = "monitors")
      @JsonProperty
      public List&lt;ProbeMonitor&gt; getMonitors() {
          return monitors;
      }
  }
  </code></pre>
  
  <p>The list (of type <code>ProbeMonitor</code>) have an <code>@EmbeddedId</code> defined as this:</p>
  
  <pre><code>@Embeddable
  public class ProbeMonitorId implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private String customer;
      private String name;
      private String type;
  }
  </code></pre>
  
  <p>The Child class define a primary key as the embedded id:</p>
  
  <pre><code>@Entity
  @Table(name = "PROBE_MONITORS")
  public class ProbeMonitor implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      private ProbeMonitorId id;
      private Integer active;
  
      @EmbeddedId
      @XmlElement
      @JsonProperty
      public ProbeMonitorId getId() {
          return id;
      }
  }
  </code></pre>
  
  <p>When i create an entity of <code>ProbeCustomer</code> and i try to call the save method (using <code>CrudRepository</code>)
  I get the following (wrong insert statement) - in the insert there are more field than i have wrote there, i've removed for brevity:</p>
  
  <pre><code>insert into PROBE_CUSTOMERS (Df_Hostname, Dt_Insert, Df_Customer, Dt_Update, id) values (?, ?, ?, ?, ?)
  insert into PROBE_MONITORS (Fl_Active, Dt_Insert, Dt_Update, Df_Customer, Df_Monitor, Df_Type) values (?, ?, ?, ?, ?, ?)
  insert into Probe_Monitors (Df_Customer, monitors_Df_Customer, monitors_Df_Monitor, monitors_Df_Type) values (?, ?, ?, ?)
  </code></pre>
  
  <p>Where i wrong defining the relationship ?</p>