Advertisement
Guest User

Course

a guest
Feb 26th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1. package university;
  2.  
  3. import Base.BaseEntity;
  4. import javax.persistence.*;
  5. import java.util.Set;
  6.  
  7.  
  8. @Entity
  9. @Table(name = "courses", schema = "university_db", catalog = "university_db")
  10. public class Course extends BaseEntity {
  11.     private String name;
  12.     private String description;
  13.     private String startDate;
  14.     private String endDate;
  15.     private double credits;
  16.     private Set<Student> students;
  17.     private Teacher teacher;
  18.  
  19.     public Course() {
  20.     }
  21.  
  22.     @Column(name = "name", nullable = false, unique = true)
  23.     public String getName() {
  24.         return name;
  25.     }
  26.  
  27.     public void setName(String name) {
  28.         this.name = name;
  29.     }
  30.  
  31.     @Column(name = "description")
  32.     public String getDescription() {
  33.         return description;
  34.     }
  35.  
  36.     public void setDescription(String description) {
  37.         this.description = description;
  38.     }
  39.  
  40.     @Column(name = "start_date")
  41.     public String getStartDate() {
  42.         return startDate;
  43.     }
  44.  
  45.     public void setStartDate(String startDate) {
  46.         this.startDate = startDate;
  47.     }
  48.  
  49.     @Column(name = "end_date")
  50.     public String getEndDate() {
  51.         return endDate;
  52.     }
  53.  
  54.     public void setEndDate(String endDate) {
  55.         this.endDate = endDate;
  56.     }
  57.  
  58.     @Column(name = "credits")
  59.     public double getCredits() {
  60.         return credits;
  61.     }
  62.  
  63.     public void setCredits(double credits) {
  64.         this.credits = credits;
  65.     }
  66.  
  67.     @ManyToMany(mappedBy = "courses", targetEntity = Student.class,
  68.             fetch = FetchType.LAZY, cascade = CascadeType.ALL)
  69.     public Set<Student> getStudents() {
  70.         return students;
  71.     }
  72.  
  73.     public void setStudents(Set<Student> students) {
  74.         this.students = students;
  75.     }
  76.  
  77.     @ManyToOne
  78.     @JoinColumn(name="teacher_id", referencedColumnName = "id")
  79.     public Teacher getTeacher() {
  80.         return teacher;
  81.     }
  82.  
  83.     public void setTeacher(Teacher teacher) {
  84.         this.teacher = teacher;
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement