1 package myorg.relex.many2one;
2
3 import java.util.Date;
4
5 import javax.persistence.*;
6
7
8
9
10
11 @Entity
12 @Table(name="RELATIONEX_ITEM")
13 public class Item {
14 @EmbeddedId
15 private ItemPK id;
16
17 @ManyToOne(optional=false)
18 @MapsId("typeId")
19 @JoinColumn(name="TYPE_ID")
20 private ItemType itemType;
21
22 @Temporal(TemporalType.TIMESTAMP)
23 private Date created;
24
25 protected Item() {}
26 public Item(ItemType itemType, int number) {
27 this.itemType = itemType;
28
29 this.id = new ItemPK().setNumber(number);
30 }
31
32 public ItemPK getId() { return id; }
33 public ItemType getItemType() { return itemType; }
34
35 public Date getCreated() { return created; }
36 public void setCreated(Date created) {
37 this.created = created;
38 }
39
40 @Override
41 public String toString() {
42 return (itemType==null?null:itemType) + "pk=" + id;
43 }
44 }