View Javadoc
1   package ejava.examples.orm.core.mapped;
2   
3   import javax.persistence.*;
4   
5   import ejava.examples.orm.core.MowerPK;
6   
7   /**
8    * This class provides an example of expressing an IdClass for a compound 
9    * primary key using annotations. The primary key class does not use 
10   * annotations. All annotations are within the using class.
11   * 
12   */
13  @Entity
14  @Table(name="ORMCORE_MOWER")
15  @IdClass(MowerPK.class)
16  public class Mower {
17      @Id
18      private String make;
19      @Id
20      private String model;    
21      private int size;
22      
23      
24      public Mower() {}
25      public Mower(String make, String model) {
26          this.make = make;
27          this.model = model;
28      }
29      
30      public String getMake() { return make; }
31      public String getModel() { return model; }
32  
33      public int getSize() { return size; }
34      public void setSize(int size) {
35          this.size = size;
36      }
37      
38      public String toString() {
39          return super.toString() +
40             ", make=" + make +
41             ", model=" + model +
42             ", size=" + size;
43      }
44  
45  }