View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import java.util.Date;
4   
5   import javax.persistence.*;
6   
7   /**
8    * This class provides an entity sub-class example for a join inheritance
9    * strategy. The parent class will define a table and primary key value.
10   * This class and all derived classes will form separate tables that are joined
11   * by primary key.
12   */
13  @Entity 
14  @Table(name="ORMINH_EMPLOYEE") //joined with Person table to form Employee
15  public class Employee extends Person {
16      private double payrate;
17      @Temporal(TemporalType.DATE)
18      private Date hireDate;
19      
20      public Employee() {}
21      public Employee(long id) { super(id); }
22      
23      public Date getHireDate() { return hireDate; }
24      public void setHireDate(Date hireDate) {
25          this.hireDate = hireDate;
26      }
27      
28      public double getPayrate() { return payrate; }
29      public void setPayrate(double payrate) {
30          this.payrate = payrate;
31      }
32      
33      public String toString() {
34          StringBuilder text = new StringBuilder(super.toString());
35          text.append(", payrate=" + payrate);
36          return text.toString();
37      }
38  }