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