View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6   * This class provides an example of an entity sub-class that is part of a 
7   * mixed strategy of inheritance. The root base class is a non-entity and 
8   * the immediate base class uses a join table strategy. That means that a table
9   * will be created to hold the unque properties of this class and joined with
10  * the parent table.
11   *
12   */
13  @Entity @Table(name="ORMINH_RECTANGLE")
14  public class Rectangle extends Shape {
15      private int height;
16      private int width;
17  
18      @Transient
19      public String getName() {
20          return "rectangle:" + getId();
21      }
22  
23      public int getHeight() {
24          return height;
25      }
26      public void setHeight(int height) {
27          this.height = height;
28      }
29  
30      public int getWidth() {
31          return width;
32      }
33      public void setWidth(int width) {
34          this.width = width;
35      }
36  
37      public String toString() {
38          StringBuilder text = new StringBuilder(super.toString());
39          text.append(", height=" + height);
40          text.append(", width=" + width);
41          return text.toString();
42      }
43  }