1 package ejava.examples.orm.core.annotated;
2
3 import java.math.BigDecimal;
4
5 import javax.persistence.*;
6
7
8
9
10
11 @Entity
12 @Table(name="ORMCORE_CAR")
13
14
15 public class Car {
16 @Id
17 @Column(name="CAR_ID", nullable=false)
18 private long id;
19
20 @Column(name="CAR_MAKE",
21 unique=false,
22 nullable=false,
23 insertable=true,
24 updatable=true,
25
26 length=20)
27 private String make;
28
29 @Column(name="CAR_MODEL", nullable=false, length=20)
30 private String model;
31
32 @Column(name="CAR_YEAR", nullable=false)
33 private int year;
34
35 @Column(name="CAR_COST", precision=7, scale=2)
36 private BigDecimal cost;
37
38 public Car() {}
39 public Car(long id) { this.id = id; }
40
41 public long getId() { return id; }
42
43 public String getMake() { return make; }
44 public void setMake(String make) {
45 this.make = make;
46 }
47
48 public String getModel() { return model; }
49 public void setModel(String model) {
50 this.model = model;
51 }
52
53 public int getYear() { return year; }
54 public void setYear(int year) {
55 this.year = year;
56 }
57
58 public BigDecimal getCost() { return cost; }
59 public void setCost(BigDecimal cost) {
60 this.cost = cost;
61 }
62
63 @Override
64 public String toString() {
65 StringBuilder builder = new StringBuilder();
66 builder.append(super.toString())
67 .append(", id=").append(id)
68 .append(", make=").append(make)
69 .append(", model=").append(model)
70 .append(", year=").append(year)
71 .append(", cost=$").append(cost);
72 return builder.toString();
73 }
74
75 }