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_PEN")
13 public class Pen {
14 @EmbeddedId
15 @AttributeOverrides({
16 @AttributeOverride(name="make", column=@Column(name="PEN_MAKE")),
17 @AttributeOverride(name="model", column=@Column(name="PEN_MODEL"))
18 })
19 private MakeModelPK pk;
20 private int size;
21
22 public Pen() {}
23 public Pen(String make, String model) {
24 this.pk = new MakeModelPK(make, model);
25 }
26
27 public MakeModelPK getPk() { return pk; }
28
29 public int getSize() { return size; }
30 public void setSize(int size) {
31 this.size = size;
32 }
33
34 public String toString() {
35 return new StringBuilder()
36 .append(super.toString())
37 .append("pk=").append(pk)
38 .append(", size=").append(size)
39 .toString();
40 }
41 }