View Javadoc
1   package ejava.examples.orm.onetomany.annotated;
2   
3   import javax.persistence.*;
4   
5   /** 
6    * This class implements the many side of a uni-directional One-to-Many
7    * relationship. It knows nothing of the parent.
8    */
9   @Entity(name="O2MChild") @Table(name="ORMO2M_CHILD")
10  public class OneManyChild {
11      @Id @GeneratedValue @Column(name="CHILDID")
12      private long id;
13      private String name;
14      
15      
16      public OneManyChild() {}
17      public OneManyChild(long id) { this.id=id; }
18      public OneManyChild(String name) { this.name = name; }
19  
20      
21      public long getId() { return id; }
22  
23      public String getName() { return name; }
24      public void setName(String name) {
25          this.name = name;
26      }
27      
28      public String toString() {
29          StringBuilder text = new StringBuilder();
30          text.append("id=" + id);
31          text.append(", name=" + name);
32          return text.toString();
33      }
34  }