View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example base class in a join inheritance strategy.
7    * In this mode, the base and all derived classes declare their own table
8    * and all are joined using a common primary key.
9    */
10  
11  @Entity @Table(name="ORMINH_PERSON")
12  @Inheritance(strategy=InheritanceType.JOINED)
13  public class Person {
14      @Id @GeneratedValue
15      private long id;
16      private String firstName;
17      private String lastName;
18      
19      public Person() {}
20      public Person(long id) { this.id=id; }
21      public long getId() { return id; }
22  
23      public String getFirstName() { return firstName; }
24      public void setFirstName(String firstName) {
25          this.firstName = firstName;
26      }
27      
28      public String getLastName() { return lastName; }
29      public void setLastName(String lastName) {
30          this.lastName = lastName;
31      }
32      
33      public String toString() {
34          StringBuilder text = new StringBuilder(super.toString());
35          text.append(", id=" + id);
36          text.append(", firstName=" + firstName);
37          text.append(", lastName=" + lastName);
38          return text.toString();
39      }
40  }