View Javadoc
1   package ejava.examples.orm.core.annotated;
2   
3   import javax.persistence.*;
4   
5   /**
6    * This class provides an example of a entity mapped to the database using 
7    * a generated primary key AUTO-matically generated by the Java Persistence 
8    * provider (i.e., not using the database for key value).
9    */
10  @Entity
11  @Table(name="ORMCORE_DRILL")
12  public class Drill  {
13      @Id
14      @GeneratedValue( //AUTO is the default and could be left off here
15              strategy=GenerationType.AUTO) 
16      private long id; //unassigned PK value must be zero
17      private String make;
18      
19      public Drill() {}
20      public Drill(long id) { this.id = id; }
21      
22      public long getId() { return id; }
23      
24      public String getMake() { return make; }
25      public void setMake(String make) {
26          this.make = make;
27      }
28      
29      @Override
30      public String toString() {
31          return new StringBuilder()
32                .append(super.toString())
33                .append(", id=").append(id)
34                .append(", make=").append(make)
35                .toString();
36      }    
37  }