1 package org.myorg.jpatickets.bo;
2
3 import java.io.Serializable;
4
5 import javax.persistence.Column;
6 import javax.persistence.Embeddable;
7
8 @Embeddable
9 public class SeatPK implements Serializable {
10 private static final long serialVersionUID = -5824145862784177861L;
11
12 private String venueId;
13 @Column(name="SECTION", length=6)
14 private String section;
15 @Column(name="ROW")
16 private int row;
17 @Column(name="POSTION")
18 private int position;
19
20 protected SeatPK() {}
21
22 public SeatPK(String venueId, String section, int row, int position) {
23 this.venueId = venueId;
24 this.section = section;
25 this.row = row;
26 this.position = position;
27 }
28
29 public String getVenueId() { return venueId; }
30 public String getSection() { return section; }
31 public int getRow() { return row; }
32 public int getPosition() { return position; }
33
34 @Override
35 public int hashCode() {
36 final int prime = 31;
37 int result = 1;
38 result = prime * result + position;
39 result = prime * result + row;
40 result = prime * result + ((section == null) ? 0 : section.hashCode());
41 result = prime * result + ((venueId == null) ? 0 : venueId.hashCode());
42 return result;
43 }
44
45 @Override
46 public boolean equals(Object obj) {
47 if (this == obj) { return true; }
48 if (obj == null) { return false; }
49 if (getClass() != obj.getClass()) { return false; }
50 SeatPK other = (SeatPK) obj;
51 return (position == other.position) &&
52 (row == other.row) &&
53 (section==null ? other.section==null : section.equals(other.section)) &&
54 (venueId==null ? other.venueId==null : venueId.equals(other.venueId));
55 }
56
57 @Override
58 public String toString() {
59 StringBuilder builder = new StringBuilder();
60 builder.append("SeatPK [venueId=").append(venueId)
61 .append(", section=").append(section)
62 .append(", row=").append(row)
63 .append(", position=").append(position)
64 .append("]");
65 return builder.toString();
66 }
67
68
69 }