bzr branch
http://gegoxaren.bato24.eu/bzr/magstudentportal/trunk
6.1.1
by Gustav Hartvigsson
Started work on the DB/JPA stuffs |
1 |
package DB; |
2 |
||
3 |
import java.io.Serializable; |
|
15.1.3
by Gustav Hartvigsson
Generated classes from tables and added them. |
4 |
import javax.persistence.*; |
5 |
import java.util.List; |
|
6 |
||
7 |
||
8 |
/**
|
|
9 |
* The persistent class for the course database table.
|
|
10 |
*
|
|
11 |
*/
|
|
6.1.1
by Gustav Hartvigsson
Started work on the DB/JPA stuffs |
12 |
@Entity
|
15.1.3
by Gustav Hartvigsson
Generated classes from tables and added them. |
13 |
@Table(name="course") |
14 |
@NamedQuery(name="Course.findAll", query="SELECT c FROM Course c") |
|
6.1.1
by Gustav Hartvigsson
Started work on the DB/JPA stuffs |
15 |
public class Course implements Serializable { |
15.1.3
by Gustav Hartvigsson
Generated classes from tables and added them. |
16 |
private static final long serialVersionUID = 1L; |
17 |
private Integer id; |
|
18 |
private String description; |
|
19 |
private String name; |
|
20 |
private List<Lecture> lectures; |
|
21 |
||
22 |
public Course() { |
|
23 |
} |
|
24 |
||
25 |
||
26 |
@Id |
|
27 |
@GeneratedValue(strategy=GenerationType.AUTO) |
|
28 |
@Column(unique=true, nullable=false) |
|
29 |
public Integer getId() { |
|
30 |
return this.id; |
|
31 |
} |
|
32 |
||
33 |
public void setId(Integer id) { |
|
34 |
this.id = id; |
|
35 |
} |
|
36 |
||
37 |
||
38 |
@Column(length=2147483647) |
|
39 |
public String getDescription() { |
|
40 |
return this.description; |
|
41 |
} |
|
42 |
||
43 |
public void setDescription(String description) { |
|
44 |
this.description = description; |
|
45 |
} |
|
46 |
||
47 |
||
48 |
@Column(length=30) |
|
49 |
public String getName() { |
|
50 |
return this.name; |
|
51 |
} |
|
52 |
||
53 |
public void setName(String name) { |
|
54 |
this.name = name; |
|
55 |
} |
|
56 |
||
57 |
||
58 |
//bi-directional many-to-one association to Lecture |
|
59 |
@OneToMany(mappedBy="courseBean") |
|
60 |
public List<Lecture> getLectures() { |
|
61 |
return this.lectures; |
|
62 |
} |
|
63 |
||
64 |
public void setLectures(List<Lecture> lectures) { |
|
65 |
this.lectures = lectures; |
|
66 |
} |
|
67 |
||
68 |
public Lecture addLecture(Lecture lecture) { |
|
69 |
getLectures().add(lecture); |
|
70 |
lecture.setCourseBean(this); |
|
71 |
||
72 |
return lecture; |
|
73 |
} |
|
74 |
||
75 |
public Lecture removeLecture(Lecture lecture) { |
|
76 |
getLectures().remove(lecture); |
|
77 |
lecture.setCourseBean(null); |
|
78 |
||
79 |
return lecture; |
|
80 |
} |
|
81 |
||
82 |
}
|