/magstudentportal/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/magstudentportal/trunk

« back to all changes in this revision

Viewing changes to src/main/java/DB/Course.java

  • Committer: Gustav Hartvigsson
  • Date: 2017-08-17 11:10:50 UTC
  • mto: (15.1.9 magstudentportal-more-db)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: gustav.hartvigsson@gmail.com-20170817111050-bloyo5ujotddqdnd
Generated classes from tables and added them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
package DB;
2
2
 
3
 
import javax.persistence.Column;
4
 
import javax.persistence.Entity;
5
 
import javax.persistence.GeneratedValue;
6
 
import javax.persistence.Id;
7
 
import javax.validation.constraints.NotNull;
8
3
import java.io.Serializable;
9
 
import java.util.UUID;
10
 
 
 
4
import javax.persistence.*;
 
5
import java.util.List;
 
6
 
 
7
 
 
8
/**
 
9
 * The persistent class for the course database table.
 
10
 * 
 
11
 */
11
12
@Entity
 
13
@Table(name="course")
 
14
@NamedQuery(name="Course.findAll", query="SELECT c FROM Course c")
12
15
public class Course implements Serializable {
13
 
 
14
 
  @Id
15
 
  @GeneratedValue
16
 
  public UUID id;
17
 
 
18
 
  @NotNull
19
 
  @Column (name = "name", length = 50)
20
 
  public String name;
21
 
 
22
 
  @NotNull
23
 
  @Column (columnDefinition = "TEXT", name = "description")
24
 
  private String description;
25
 
 
26
 
  public UUID
27
 
  getId () {
28
 
    return id;
29
 
  }
30
 
 
31
 
  public void
32
 
  setId (UUID id) {
33
 
    this.id = id;
34
 
  }
35
 
 
36
 
  public String
37
 
  getName () {
38
 
    return name;
39
 
  }
40
 
 
41
 
  public void
42
 
  setName (String name) {
43
 
    this.name = name;
44
 
  }
45
 
 
46
 
  public String
47
 
  getDescription () {
48
 
    return description;
49
 
  }
50
 
 
51
 
  public void
52
 
  setDescription (String description) {
53
 
    this.description = description;
54
 
  }
55
 
}
 
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
}
 
 
b'\\ No newline at end of file'