View Javadoc
1   package ejava.examples.orm.inheritance.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example entity class that derives from a non-entity
7    * class and accepts all mapping defaults. @see Album class for a sibling 
8    * example where several of the default mappings have been overridden.
9    */
10  @Entity 
11  @Table(name="ORMINH_TOOTHPASTE") //table holds this entity and parent class
12  public class ToothPaste extends BaseObject {
13  	@Access(AccessType.FIELD)
14      private int size;
15  
16      @Id @GeneratedValue //id is being generated independent of other siblings
17      public long getId() { return super.getId(); }
18      protected void setId(long id) {
19          super.setId(id);
20      }
21      
22      public int getSize() { return size; }
23      public void setSize(int size) {
24          this.size = size;
25      }
26  
27      @Transient
28      public String getName() { return "" + size + "oz toothpaste"; }
29      
30      public String toString() {
31          StringBuilder text = new StringBuilder(super.toString());
32          return text.toString();
33      }
34  }