KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > example > Grade


1 package example;
2
3 import java.util.Collection JavaDoc;
4
5 import javax.persistence.*;
6
7 /**
8  * Implementation class for the Student bean.
9  *
10  * <code><pre>
11  * CREATE TABLE amber_many2many_map (
12  * grade_id INTEGER PRIMARY KEY auto_increment,
13  *
14  * student_id INTEGER REFERENCES Student(student_id)
15  * course_id INTEGER REFERENCES Course(course_id)
16  * );
17  * </pre></code>
18  */

19 @Entity
20 @Table(name="amber_many2many_map")
21 public class Grade {
22   private long _id;
23   private Student _student;
24   private Course _course;
25   private String JavaDoc _grade;
26
27   public Grade()
28   {
29   }
30
31   public Grade(Student student, Course course, String JavaDoc grade)
32   {
33     setStudent(student);
34     setCourse(course);
35     setGrade(grade);
36   }
37
38   /**
39    * Gets the id.
40    */

41   @Id
42   @Column(name="grade_id")
43   @GeneratedValue
44   public long getId()
45   {
46     return _id;
47   }
48
49   /**
50    * Sets the id.
51    */

52   public void setId(long id)
53   {
54     _id = id;
55   }
56
57   /**
58    * Gets the grade.
59    */

60   @Basic
61   public String JavaDoc getGrade()
62   {
63     return _grade;
64   }
65
66   /**
67    * Sets the grade.
68    */

69   public void setGrade(String JavaDoc grade)
70   {
71     _grade = grade;
72   }
73   
74   /**
75    * Returns the student.
76    */

77   @ManyToOne
78   @JoinColumn(name="student_id", nullable=false, updatable=false)
79   public Student getStudent()
80   {
81     return _student;
82   }
83   
84   /**
85    * Sets the student.
86    */

87   public void setStudent(Student student)
88   {
89     _student = student;
90   }
91   
92   /**
93    * Returns the course.
94    */

95   @ManyToOne
96   @JoinColumn(name="course_id", nullable=false, updatable=false)
97   public Course getCourse()
98   {
99     return _course;
100   }
101   
102   /**
103    * Sets the course.
104    */

105   public void setCourse(Course course)
106   {
107     _course = course;
108   }
109 }
110
Popular Tags