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   * @author jcstaff
13   * $Id:$
14   */
15  @Entity
16  @Table(name="ORMCORE_MOWER")
17  @IdClass(MowerPK.class)
18  public class Mower {
19      @Id
20      private String make;
21      @Id
22      private String model;    
23      private int size;
24      
25      
26      public Mower() {}
27      public Mower(String make, String model) {
28          this.make = make;
29          this.model = model;
30      }
31      
32      public String getMake() { return make; }
33      public String getModel() { return model; }
34  
35      public int getSize() { return size; }
36      public void setSize(int size) {
37          this.size = size;
38      }
39      
40      public String toString() {
41          return super.toString() +
42             ", make=" + make +
43             ", model=" + model +
44             ", size=" + size;
45      }
46  
47  }