From 57fa63edb7a2879ae769f147e0ce4babde9d3062 Mon Sep 17 00:00:00 2001 From: Jan Vales Date: Thu, 29 Mar 2018 00:32:10 +0200 Subject: [PATCH] Model fixes to remove unneeded tables. --- .../src/main/java/dst/ass1/jpa/model/impl/Course.java | 9 ++++++--- .../src/main/java/dst/ass1/jpa/model/impl/Lecturer.java | 2 +- .../src/main/java/dst/ass1/jpa/model/impl/Lesson.java | 1 + .../main/java/dst/ass1/jpa/model/impl/Participant.java | 2 ++ .../src/main/java/dst/ass1/jpa/model/impl/Person.java | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Course.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Course.java index 0ceb118..53bb59a 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Course.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Course.java @@ -45,20 +45,23 @@ public class Course implements ICourse { @Column private Date end; - // , optional = false? + // FIXME: TESTS VS DB-MODEL? (optional = false) @ManyToOne(targetEntity = CoursePlatform.class) + @JoinColumn(name = Constants.I_COURSEPLATFORM) private ICoursePlatform coursePlatform; - // , optional = false? + // FIXME: TESTS VS DB-MODEL? (optional = false) @ManyToOne(targetEntity = Lecturer.class) + @JoinColumn(name = Constants.I_LECTURER) private ILecturer lecturer; - @OneToMany(targetEntity = Lesson.class) + @OneToMany(targetEntity = Lesson.class, mappedBy = Constants.M_LESSON_COURSE) private Collection lessons = new ArrayList<>(); @OneToOne(targetEntity = Metadata.class, optional = false, cascade = CascadeType.ALL) private IMetadata metadata; + // FIXME: TESTS VS DB-MODEL? @OneToMany(targetEntity = Enrollment.class) private Collection enrollments = new ArrayList<>(); diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java index 988527d..443f85b 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lecturer.java @@ -23,7 +23,7 @@ import java.util.Collection; " WHERE les.course = :course AND les.start > :now" + " ORDER BY les.start") public class Lecturer extends Person implements ILecturer { - @OneToMany(targetEntity = Course.class) + @OneToMany(targetEntity = Course.class, mappedBy = Constants.M_COURSE_LECTURER) private Collection courses = new ArrayList<>(); @ManyToMany(targetEntity = Lesson.class) diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lesson.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lesson.java index 181fded..fd10f7e 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lesson.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Lesson.java @@ -28,6 +28,7 @@ public class Lesson implements ILesson { private Date end; @ManyToOne(targetEntity = Course.class) + @JoinColumn(name = Constants.I_COURSE) private ICourse course; @ManyToMany(targetEntity = Lecturer.class, mappedBy = Constants.M_LECTURER_LESSONS) diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java index 4213334..c983eda 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Participant.java @@ -27,9 +27,11 @@ public class Participant extends Person implements IParticipant { @Column private String bankCode; + // FIXME: TESTS VS DB-MODEL? @OneToMany(targetEntity = Enrollment.class) private Collection enrollments = new ArrayList<>(); + // FIXME: TESTS VS DB-MODEL? @OneToMany(targetEntity = Membership.class) private Collection memberships = new ArrayList<>(); diff --git a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java index eca46d5..d927f40 100644 --- a/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java +++ b/ass1-jpa/src/main/java/dst/ass1/jpa/model/impl/Person.java @@ -14,7 +14,7 @@ public abstract class Person implements IPerson { @GeneratedValue private Long id; - @Column() + @Column private String name; @Embedded -- 2.43.0