title: Hibernate JPA ManyToOne composite key
body: <p>I'm trying to setup my entity to allow to pks. My database consist of two fields,</p>
  
  <p>dealer_detail_id pk
  user_detail_id pk</p>
  
  <p>Both join on id in corresponding tables. </p>
  
  <p>I've tried this thus far without success. </p>
  
  <pre><code>@Embeddable
  public class DealerUserPk implements Serializable {
  
      private Integer dealerDetail;
      private Integer userDetail;
  </code></pre>
  
  <p>DealerUser</p>
  
  <pre><code>@Embeddable
  @Table(name = "dealer_user", schema = "account") 
  public class DealerUser implements Serializable {
  
      @EmbeddedId
      private DealerUserPk id;
  
      @Id
      @ManyToOne
      @JoinColumn(name = "dealer_detail_id", referencedColumnName = "id")
      private DealerDetail dealerDetail;
  
      @Id
      @ManyToOne
      @JoinColumn(name = "user_detail_id", referencedColumnName = "id")
      private UserDetail userDetail;
  </code></pre>
  
  <p>DealerDetail</p>
  
  <pre><code>@Entity
  @Table(name = "dealer_detail", schema = "account") 
  public class DealerDetail implements Serializable {
  
      @Id
      private Integer id;
  </code></pre>
  
  <p>UserDetail</p>
  
  <pre><code>@Entity
  @Table(name = "user_detail", schema = "account") 
  public class UserDetail implements Serializable {
  
      @Id
      private Integer id;
  </code></pre>
  
  <p>Can anybody spot what I'm doing wrong?</p>