title: Hibernate Jpa Annotation: Problem with Embedded Id
body: <p>I have this schema of db:</p>
  
  <p>Table_A[1]-->[n]Table_C
  and 
  Table_B[1]-->[n]Table_C</p>
  
  <p>Now, the PrimaryKey of Table_C is a EmbeddedId with Foreign key versus Table_A and Foreign Key versus Table_B. How do I note this annotation?</p>
  
  <p>My solution is:</p>
  
  <pre><code>@Entity
  public class TableA{
      @Id @column(name="ID")
      public int id;
  
      @OneToMany(mappedBy="tableA")
      public List&lt;TableC&gt; listOftableC; 
  }
  
  @Entity
  public class TableB{
      @Id @column(name="ID")
      public String id;
  
      @OneToMany(mappedBy="tableB")
      public List&lt;TableC&gt; listOftableC; 
  
  }
  
  @Entity
  public class TableC{
      @EmbeddedId
      public TableCPK idComposite;
  }
  
  @Embeddable
  public class TableCPK{
  
      @ManyToOne
      @JoinColumn(name = "ID_TABLE_A", referencedColumnName="ID")
      public TableA tableA;
  
      @ManyToOne
      @JoinColumn(name = "ID_TABLE_B", referencedColumnName="ID")
      public TableA tableB;
  }
  </code></pre>