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