title: Using @Id for multiple fields in same class
body: <p>I am a newbie to Hibernate and have to support an existing application that uses Hibernate
      It is a pure reporting application - no insert / update / delete - only selects</p>
  
  <p>I can see existing POJO objects which have the @Id annotation used in more than one field in the same class </p>
  
  <p>My understanding was that for a composite primary key - you need to use @Embeddable and @EmbeddedId</p>
  
  <p>However this is not defined in my class and the strange thing is code compiles and runs just fine </p>
  
  <p>Here is an example of my code :</p>
  
  <pre><code>package com.xyz.vo;
  
  import java.io.Serializable;
  import javax.persistence.*;
  import org.hibernate.annotations.GenericGenerator;
  
  @Entity(name="com.xyz.vo.Emp")
  @Table(name = "TEmployee")
  public class Emp implements Serializable    {
  private java.lang.Integer  empId;
  @Id 
  @Column(name = "EMP_ID")   
  public java.lang.Integer  getEmpId(){   
      return this.empId;
  }
  
  public  void  setEmpId(java.lang.Integer empId){    
      this.empId=empId;
  }
  
  private java.lang.Integer  empAge;
  @Id 
  @Column(name = "EMP_AGE")   
  public java.lang.Integer  getEmpAge(){  
      return this.empAge;
  }
  
      public  void  setEmpAge(java.lang.Integer empAge){  
      this.empAge=empAge;
  }
  
      private String empName;
      @Column(name = "EMP_NAME")   
  public String  getEmpName(){    
      return this.empName;
  }
  
      public  void  setEmpName(String empName){   
      this.empName=empName;
  }
  </code></pre>
  
  <p>and many more fields in the pojo - which do not have the @Id defined </p>
  
  <p>NOTE - here two fields have the @Id annotation </p>
  
  <p>I am confused why this compiles and works ?
  Thanks
  akila</p>