View Javadoc
1   package ejava.examples.orm.core.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class demonstrates the use of IDENTITY generator strategy using
7    * annotations.
8    */
9   @Entity
10  @Table(name="ORMCORE_GADGET")
11  public class Gadget {
12      @Id
13      @GeneratedValue(strategy=GenerationType.IDENTITY)
14      private long id;
15      private String make;    
16      
17      public Gadget() {}
18      public Gadget(long id) { this.id = id; }
19      
20      public long getId() { return id; }
21  
22      public String getMake() { return make; }
23      public void setMake(String make) {
24          this.make = make;
25      }
26  
27      @Override
28      public String toString() {
29          return new StringBuilder()
30                .append(super.toString())	       
31                .append(", id=").append(id)
32                .append(", make=").append(make)
33                .toString();
34      }    
35  }