1 package ejava.examples.orm.core.annotated;
2
3 import javax.persistence.*;
4
5
6
7
8
9
10
11
12 @Entity
13 @Table(name="ORMCORE_TANK")
14 public class Tank {
15 private long id;
16 private String make;
17 private String model;
18
19 public Tank() {}
20 public Tank(long id) { this.id = id; }
21
22 @Id
23 public long getId() { return id; }
24 protected void setId(long id) {
25 this.id = id;
26 }
27
28 @Transient
29 public String getMakeModel() {
30 return make + " " + model;
31 }
32
33 public String getMake() { return make; }
34 public void setMake(String make) {
35 this.make = make;
36 }
37
38 public String getModel() { return model; }
39 public void setModel(String model) {
40 this.model = model;
41 }
42
43 public String toString() {
44 return new StringBuilder()
45 .append(super.toString())
46 .append("make=").append(make)
47 .append(", model=").append(model)
48 .toString();
49 }
50 }