1 package ejava.examples.orm.rel.composite;
2
3 import java.io.Serializable;
4
5 import javax.persistence.Column;
6 import javax.persistence.Embeddable;
7
8 @Embeddable
9 public class DoorPK implements Serializable {
10 private static final long serialVersionUID = -5621257030133324800L;
11 @Column(name="PK_HOUSE_ID")
12 private int houseId;
13 @Column(name="PK_DOOR_ID")
14 private int doorId;
15
16 public DoorPK() {}
17 public DoorPK(int houseId, int doorId) {
18 this.houseId=houseId;
19 this.doorId=doorId;
20 }
21
22 public int getHouseId() { return houseId; }
23 public int getDoorId() { return doorId; }
24
25 @Override
26 public int hashCode() {
27 return houseId + doorId;
28 }
29
30 @Override
31 public boolean equals(Object obj) {
32 try {
33 if (obj==null) { return false; }
34 if (this==obj) { return true; }
35 DoorPK rhs = (DoorPK)obj;
36 return houseId==rhs.houseId && doorId==rhs.doorId;
37 } catch (Exception ex) { return false; }
38 }
39 }