1 package ejava.examples.orm.rel.composite; 2 3 import java.io.Serializable; 4 5 public class ResidentPK implements Serializable { 6 private static final long serialVersionUID = -8638522228922200157L; 7 private int house; 8 private int residentId; 9 10 public ResidentPK() {} 11 public ResidentPK(int houseId, int residentId) { 12 this.house=houseId; 13 this.residentId=residentId; 14 } 15 16 public int getHouseId() { return house; } 17 public int getResidentId() { return residentId; } 18 19 @Override 20 public int hashCode() { 21 return house + residentId; 22 } 23 24 @Override 25 public boolean equals(Object obj) { 26 try { 27 if (obj==null) { return false; } 28 if (this==obj) { return true; } 29 ResidentPK rhs = (ResidentPK)obj; 30 return house==rhs.house && residentId==rhs.residentId; 31 } catch (Exception ex) { return false; } 32 } 33 }