01: package example;
02:
03: import javax.persistence.Basic;
04: import javax.persistence.Column;
05: import javax.persistence.Entity;
06: import javax.persistence.GeneratedValue;
07: import javax.persistence.Id;
08: import javax.persistence.Table;
09:
10: /**
11: * Local interface for a course taught at Hogwarts, providing
12: * methods to view and change it.
13: *
14: * <code><pre>
15: * CREATE TABLE ejb3_basic_courses (
16: * id INTEGER
17: * course VARCHAR(250),
18: * teacher VARCHAR(250),
19: *
20: * PRIMARY KEY(course_id)
21: * );
22: * </pre></code>
23: */
24: @Entity
25: @Table(name="ejb3_basic_courses")
26: public class CourseBean {
27: private int _id;
28: private String _course;
29: private String _teacher;
30:
31: /**
32: * Returns the ID of the course.
33: */
34: @Id
35: @Column(name="id")
36: @GeneratedValue
37: public int getId() {
38: return _id;
39: }
40:
41: public void setId(int id) {
42: _id = id;
43: }
44:
45: /**
46: * Returns the course name.
47: */
48: @Basic
49: public String getCourse() {
50: return _course;
51: }
52:
53: /**
54: * Sets the course name.
55: */
56: public void setCourse(String course) {
57: _course = course;
58: }
59:
60: /**
61: * Returns the teacher name.
62: */
63: @Basic
64: public String getTeacher() {
65: return _teacher;
66: }
67:
68: /**
69: * Sets the teacher name.
70: */
71: public void setTeacher(String teacher) {
72: _teacher = teacher;
73: }
74: }
|