01: package example;
02:
03: import java.util.Collection;
04:
05: import javax.persistence.*;
06:
07: /**
08: * Implementation class for the Student bean.
09: *
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 _grade;
26:
27: public Grade() {
28: }
29:
30: public Grade(Student student, Course course, String grade) {
31: setStudent(student);
32: setCourse(course);
33: setGrade(grade);
34: }
35:
36: /**
37: * Gets the id.
38: */
39: @Id
40: @Column(name="grade_id")
41: @GeneratedValue
42: public long getId() {
43: return _id;
44: }
45:
46: /**
47: * Sets the id.
48: */
49: public void setId(long id) {
50: _id = id;
51: }
52:
53: /**
54: * Gets the grade.
55: */
56: @Basic
57: public String getGrade() {
58: return _grade;
59: }
60:
61: /**
62: * Sets the grade.
63: */
64: public void setGrade(String grade) {
65: _grade = grade;
66: }
67:
68: /**
69: * Returns the student.
70: */
71: @ManyToOne
72: @JoinColumn(name="student_id",nullable=false,updatable=false)
73: public Student getStudent() {
74: return _student;
75: }
76:
77: /**
78: * Sets the student.
79: */
80: public void setStudent(Student student) {
81: _student = student;
82: }
83:
84: /**
85: * Returns the course.
86: */
87: @ManyToOne
88: @JoinColumn(name="course_id",nullable=false,updatable=false)
89: public Course getCourse() {
90: return _course;
91: }
92:
93: /**
94: * Sets the course.
95: */
96: public void setCourse(Course course) {
97: _course = course;
98: }
99: }
|