title: How to create JPA class for composite primary key
body: <p>I have table with composite primary keys </p>
  
  <blockquote>
    <p>site_Uid       --> from Site table<br>
    address_Uid       --> from Address
    table</p>
  </blockquote>
  
  <p>The below JPA class throws an exception</p>
  
  <pre><code>@Entity @IdClass(Site.class)
  @Table(name = "site_address")
  public class SiteAddress implements Serializable {
  
      private static final long serialVersionUID = 7237095501517057347L;
      @Id
      @Column(name = "site_uid")
      private int siteUid;
      @Column(name = "address_uid")
      @Id
      private int addressUid;
  }
  </code></pre>
  
  <p>Site Class:</p>
  
  <pre><code>@Entity
  @Table(name = "site")
  public class Site implements Serializable {
  
      private static final long serialVersionUID = 2059474818667179203L;
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private long siteUid;
      @Column(name = "party_role_uid")
      private int partyRoleUid;
      @Column(name = "site_type_cd")
      private int siteTypeCd;
      @Column(name = "site_name")
      private String siteName;
  
  }
  </code></pre>
  
  <p>Error: </p>
  
  <pre><code>Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: Unable to find properties (siteTypeCd, siteName, partyRoleUid) in entity annotated with @IdClass:com.enkindle.model.SiteAddress
  </code></pre>