View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example of mixing two inheritance stratgies; 
7    * non-entity inheritance and join. The parent of this class is a non-entity
8    * and will be stored inside this table. Since this class has also defined
9    * the inheritance stratgy to be JOIN, all sub-classes will have their own 
10   * tables and join with this table to form an object.
11   *
12   */
13  @Entity @Table(name="ORMINH_SHAPE")
14  @Inheritance(strategy=InheritanceType.JOINED)
15  public abstract class Shape extends BaseObject {
16      private int posx;
17      private int posy;
18      
19      @Id @GeneratedValue
20      public long getId()           { return super.getId(); }
21      protected void setId(long id) { super.setId(id); }
22      
23      public int getPosx() {
24          return posx;
25      }
26      public void setPosx(int posx) {
27          this.posx = posx;
28      }
29      public int getPosy() {
30          return posy;
31      }
32      public void setPosy(int posy) {
33          this.posy = posy;
34      }
35  
36      public String toString() {
37          StringBuilder text = new StringBuilder(super.toString());
38          text.append(", posx=" + posx);
39          text.append(", posy=" + posy);
40          return text.toString();
41      }
42  }