1 package ejava.examples.orm.core.mapped;
2
3 import java.io.Serializable;
4 import javax.persistence.*;
5
6
7
8
9
10
11
12 @Embeddable
13 public class NapsackPK implements Serializable {
14 private static final long serialVersionUID = 1L;
15
16 @Column(name="NAPSACK_MAKE")
17 private String make;
18 @Column(name="NAPSACK_MODEL")
19 private String model;
20
21 public NapsackPK() {}
22 public NapsackPK(String make, String model) {
23 this.make = make;
24 this.model = model;
25 }
26
27 public String getMake() { return make; }
28 public void setMake(String make) {
29 this.make = make;
30 }
31 public String getModel() { return model; }
32 public void setModel(String model) {
33 this.model = model;
34 }
35
36 public int hashCode() { return make.hashCode() + model.hashCode(); }
37 public boolean equals(Object obj) {
38 try {
39 if (this == obj) return true;
40 return make.equals(((NapsackPK)obj).getMake()) &&
41 model.equals(((NapsackPK)obj).getModel());
42
43 } catch (Throwable ignored) {
44 return false;
45 }
46 }
47
48 public String toString() {
49 return super.toString() +
50 ", make=" + make +
51 ", model=" + model;
52 }
53
54 }