1 package ejava.examples.orm.inheritance.annotated;
2
3 import java.util.Date;
4
5 import javax.persistence.*;
6
7
8
9
10
11
12
13
14 @Entity
15 @DiscriminatorValue("BREAD_TYPE")
16 public class Bread extends Product {
17 private int slices;
18 @Temporal(TemporalType.DATE)
19 private Date bakedOn;
20
21 public Bread() {}
22 public Bread(long id) { super(id); }
23
24 public Date getBakedOn() { return bakedOn;}
25 public void setBakedOn(Date bakedOn) {
26 this.bakedOn = bakedOn;
27 }
28
29 public int getSlices() { return slices; }
30 public void setSlices(int slices) {
31 this.slices = slices;
32 }
33
34 @Transient
35 public String getName() { return "Bread"; }
36
37 public String toString() {
38 StringBuilder text = new StringBuilder(super.toString());
39 text.append(", slices=" + slices);
40 text.append(", baked=" + bakedOn);
41 return text.toString();
42 }
43 }