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   * @author jcstaff
13   */
14  @Entity @Table(name="ORMINH_SHAPE")
15  @Inheritance(strategy=InheritanceType.JOINED)
16  public abstract class Shape extends BaseObject {
17      private int posx;
18      private int posy;
19      
20      @Id @GeneratedValue
21      public long getId()           { return super.getId(); }
22      protected void setId(long id) { super.setId(id); }
23      
24      public int getPosx() {
25          return posx;
26      }
27      public void setPosx(int posx) {
28          this.posx = posx;
29      }
30      public int getPosy() {
31          return posy;
32      }
33      public void setPosy(int posy) {
34          this.posy = posy;
35      }
36  
37      public String toString() {
38          StringBuilder text = new StringBuilder(super.toString());
39          text.append(", posx=" + posx);
40          text.append(", posy=" + posy);
41          return text.toString();
42      }
43  }