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