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