1 package ejava.examples.orm.core.annotated;
2
3 import javax.persistence.*;
4
5
6
7
8
9
10
11 @Entity
12 @Table(name="ORMCORE_WATCH")
13 @SecondaryTables({
14 @SecondaryTable(name="ORMCORE_OWNER",
15 pkJoinColumns={
16 @PrimaryKeyJoinColumn(name="OWNER_ID")}),
17 @SecondaryTable(name="ORMCORE_MAKER",
18 pkJoinColumns={
19 @PrimaryKeyJoinColumn(name="MAKER_ID")})
20 })
21 public class Watch {
22 @Id
23 private long id;
24 private String make;
25 private String model;
26 @Column(name="NAME", table="ORMCORE_OWNER")
27 private String owner;
28 @Column(table="ORMCORE_OWNER")
29 private String cardnum;
30 @Column(name="NAME", table="ORMCORE_MAKER")
31 private String manufacturer;
32 @Column(table="ORMCORE_MAKER")
33 private String address;
34 @Column(table="ORMCORE_MAKER")
35 private String phone;
36
37 public Watch() {}
38 public Watch(long id) { this.id = id; }
39
40 public long getId() { return id; }
41
42 public String getMake() { return make; }
43 public void setMake(String make) {
44 this.make = make;
45 }
46
47 public String getModel() { return model; }
48 public void setModel(String model) {
49 this.model = model;
50 }
51
52 public String getOwner() { return owner; }
53 public void setOwner(String owner) {
54 this.owner = owner;
55 }
56
57 public String getCardnum() { return cardnum; }
58 public void setCardnum(String cardnum) {
59 this.cardnum = cardnum;
60 }
61
62 public String getManufacturer() { return manufacturer; }
63 public void setManufacturer(String manufacturer) {
64 this.manufacturer = manufacturer;
65 }
66
67 public String getAddress() { return address; }
68 public void setAddress(String address) {
69 this.address = address;
70 }
71
72 public String getPhone() { return phone; }
73 public void setPhone(String phone) {
74 this.phone = phone;
75 }
76
77 @Override
78 public String toString() {
79 StringBuilder builder = new StringBuilder();
80 builder.append(super.toString())
81 .append(", id=").append(id)
82 .append(", make=").append(make)
83 .append(", model=").append(model)
84 .append(", owner=").append(owner)
85 .append(", cardnum=").append(cardnum)
86 .append(", manufacturer=").append(manufacturer)
87 .append(", address=").append(address)
88 .append(", phone=").append(phone);
89 return builder.toString();
90 }
91 }