View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an entity sub-class example for a join inheritance
7    * strategy. The parent class will define a table and primary key value.
8    * This class and all derived classes will form separate tables that are joined
9    * by primary key.
10   */
11  @Entity 
12  @Table(name="ORMINH_CUSTOMER") //joined with Person table to form Customer
13  public class Customer extends Person {
14      public enum Rating { GOLD, SILVER, BRONZE }
15      @Enumerated(EnumType.STRING)
16      private Rating rating;
17      
18      public Customer() {}
19      public Customer(long id) { super(id); }
20  
21      public Rating getRating() { return rating; }
22      public void setRating(Rating rating) {
23          this.rating = rating;
24      }
25      
26      public String toString() {
27          StringBuilder text = new StringBuilder(super.toString());
28          text.append(", rating=" + rating);
29          return text.toString();
30      }
31  }