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 using separate
7    * classes per-concrete derived class. This means that the base class
8    * properties will get merged into this table (similar to non-entity 
9    * inheritance).
10   */
11  @Entity
12  @Table(name="ORMINH_CHECKING")
13  public class CheckingAccount extends Account {
14      private double fee;
15      
16      public CheckingAccount() {}
17      public CheckingAccount(long id) { super(id); }
18  
19      public void withdraw(double amount) throws AccountException {
20          super.setBalance(super.getBalance() - fee);
21      }
22  
23      public double getFee() { return fee; }
24      public void setFee(double fee) {
25          this.fee = fee;
26      }
27      
28      public String toString() {
29          StringBuilder text = new StringBuilder(super.toString());
30          text.append(", fee=" + fee);
31          return text.toString();
32      }
33  }