title: java.lang.IllegalArgumentException: expecting IdClass mapping
body: <p>I have configured composite primary key for my entity <code>Employee</code> as follows</p>
  
  <p>Employee.java:</p>
  
  <pre><code>@Entity
  @Table(name="employee")
  @Proxy(lazy=false)
  @IdClass(EmployeeId.class)
  public class Employee implements Serializable {
      private static final long serialVersionUID = 1L;
  
      private EmployeeId employeeId;
      private Person person;
      private Branch branch;
      private boolean isActive;
  
      public Employee() {
  
      }    
  
      @EmbeddedId
      @AttributeOverrides({
          @AttributeOverride(name="person", column = @Column(name="person_id")),
          @AttributeOverride(name="branch", column = @Column(name="branch_id"))})
  
      public EmployeeId getEmployeeId() {
          return employeeId;
      }
  
      public void setEmployeeId(EmployeeId employeeId) {
          this.employeeId = employeeId;
      }
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="person_id")
      public Person getPerson() {
          return person;
      }
  
      public void setPerson(Person person) {
          this.person = person;
      }
  
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="branch_id")
      public Branch getBranch() {
          return branch;
      }
  
      public void setBranch(Branch branch) {
          this.branch = branch;
      }
  
      @Column(name="is_active")
      public boolean getIsActive() {
          return isActive;
      }
  
      public void setIsActive(boolean isActive) {
          this.isActive = isActive;
      }
  
  }
  </code></pre>
  
  <p>EmployeeId.java:</p>
  
  <pre><code>@Embeddable
  public class EmployeeId implements Serializable {
      private static final long serialVersionUID = 1L;
  
      private Person person;
      private Branch branch;
  
      public EmployeeId() {
  
      }
  
      public EmployeeId(Person argPerson, Branch argbranch) {
          this.person = argPerson;
          this.branch = argbranch;
      }
  
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="person_id", insertable=false, updatable=false)
      public Person getPerson() {
          return person;
      }
      public void setPerson(Person person) {
          this.person = person;
      }
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="branch_id", insertable=false, updatable=false)
      public Branch getBranch() {
          return branch;
      }
      public void setBranch(Branch branch) {
          this.branch = branch;
      }
  }
  </code></pre>
  
  <p>I created a <code>SessionFactory</code> bean using class <code>org.springframework.orm.hibernate5.LocalSessionFactoryBean</code> and mapped all <code>hbm.xml</code> as a <code>MappingLocations</code>.</p>
  
  <p>My code throws the following error:</p>
  
  <pre><code>Caused by: java.lang.IllegalArgumentException: expecting IdClass mapping
  at org.hibernate.metamodel.internal.AttributeFactory$3.resolveMember(AttributeFactory.java:971)
  at org.hibernate.metamodel.internal.AttributeFactory$5.resolveMember(AttributeFactory.java:1029)
  at org.hibernate.metamodel.internal.AttributeFactory.determineAttributeMetadata(AttributeFactory.java:451)
  at org.hibernate.metamodel.internal.AttributeFactory.buildIdAttribute(AttributeFactory.java:128)
  at org.hibernate.metamodel.internal.MetadataContext.buildIdClassAttributes(MetadataContext.java:337)
  at org.hibernate.metamodel.internal.MetadataContext.applyIdMetadata(MetadataContext.java:269)
  at org.hibernate.metamodel.internal.MetadataContext.wrapUp(MetadataContext.java:190)
  at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:219)
  at org.hibernate.internal.SessionFactoryImpl.&lt;init&gt;(SessionFactoryImpl.java:296)
  at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:476)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:707)
  at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:723)
  at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:504)
  at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:488)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFac
  </code></pre>
  
  <p>How can I avoid this error? I am using <code>spring-orm-4.3.1-RELEASE</code> and <code>hibernate-core-5.2.0.Final</code>.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I have created a sample project and I am getting the following error while running...</p>
  
  <pre><code>Caused by: org.hibernate.AnnotationException: Property of @IdClass not found in entity sample.domain.Employee: employee
  </code></pre>
  
  <p>Refer the code: <a href="https://www.dropbox.com/s/axr8l01iqh0qr29/idclass-using-hibernate5.tar.gz?dl=0">https://www.dropbox.com/s/axr8l01iqh0qr29/idclass-using-hibernate5.tar.gz?dl=0</a></p>
  
  <p>What I did wrong? Kindly provide your inputs here</p>