1 package myorg.relex.one2one;
2
3 import java.util.Date;
4
5 import javax.persistence.*;
6
7
8
9
10
11 @Entity
12 @Table(name="RELATIONEX_EMPLOYEE")
13 public class Employee {
14 @Id
15 private int id;
16
17 @OneToOne(optional=false,fetch=FetchType.EAGER)
18 @PrimaryKeyJoinColumn
19 private Person person;
20
21 @Temporal(TemporalType.DATE)
22 private Date hireDate;
23
24 protected Employee() {}
25 public Employee(Person person) {
26 this.person = person;
27 if (person != null) { id = person.getId(); }
28 }
29
30 public int getId() { return person.getId(); }
31 public Person getPerson() { return person; }
32
33 public Date getHireDate() { return hireDate; }
34 public void setHireDate(Date hireDate) {
35 this.hireDate = hireDate;
36 }
37 }