diff options
Diffstat (limited to 'src/main/java/com/stileeducation/markr/entity')
3 files changed, 232 insertions, 225 deletions
diff --git a/src/main/java/com/stileeducation/markr/entity/Student.java b/src/main/java/com/stileeducation/markr/entity/Student.java index 9ef2091..4e69eab 100644 --- a/src/main/java/com/stileeducation/markr/entity/Student.java +++ b/src/main/java/com/stileeducation/markr/entity/Student.java @@ -10,83 +10,87 @@ import java.util.Set; @Table(name = "students") public class Student { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "first_name", nullable = false) - private String firstName; - - @Column(name = "last_name", nullable = false) - private String lastName; - - @Column(name = "student_number", nullable = false, unique = true) - private String studentNumber; - - @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, orphanRemoval = true) - private Set<TestResult> testResults = new HashSet<>(); - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getStudentNumber() { - return studentNumber; - } - - public void setStudentNumber(String studentNumber) { - this.studentNumber = studentNumber; - } - - public Set<TestResult> getTestResults() { - return testResults; - } - - public void setTestResults(Set<TestResult> testResults) { - this.testResults = testResults; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Student student = (Student) o; - return Objects.equals(id, student.id) && Objects.equals(firstName, student.firstName) && Objects.equals(lastName, student.lastName) && Objects.equals(studentNumber, student.studentNumber) && Objects.equals(testResults, student.testResults); - } - - @Override - public int hashCode() { - return Objects.hash(id, firstName, lastName, studentNumber, testResults); - } - - @Override - public String toString() { - return "Student{" + - "id=" + id + - ", firstName='" + firstName + '\'' + - ", lastName='" + lastName + '\'' + - ", studentNumber='" + studentNumber + '\'' + - ", testResults=" + testResults + - '}'; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "first_name", nullable = false) + private String firstName; + + @Column(name = "last_name", nullable = false) + private String lastName; + + @Column(name = "student_number", nullable = false, unique = true) + private String studentNumber; + + @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, orphanRemoval = true) + private Set<TestResult> testResults = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getStudentNumber() { + return studentNumber; + } + + public void setStudentNumber(String studentNumber) { + this.studentNumber = studentNumber; + } + + public Set<TestResult> getTestResults() { + return testResults; + } + + public void setTestResults(Set<TestResult> testResults) { + this.testResults = testResults; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Student student = (Student) o; + return Objects.equals(id, student.id) && + Objects.equals(firstName, student.firstName) && + Objects.equals(lastName, student.lastName) && + Objects.equals(studentNumber, student.studentNumber) && + Objects.equals(testResults, student.testResults); + } + + @Override + public int hashCode() { + return Objects.hash(id, firstName, lastName, studentNumber, testResults); + } + + @Override + public String toString() { + return "Student{" + + "id=" + id + + ", firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + ", studentNumber='" + studentNumber + '\'' + + ", testResults=" + testResults + + '}'; + } }
\ No newline at end of file diff --git a/src/main/java/com/stileeducation/markr/entity/Test.java b/src/main/java/com/stileeducation/markr/entity/Test.java index 3729e1b..615d0e1 100644 --- a/src/main/java/com/stileeducation/markr/entity/Test.java +++ b/src/main/java/com/stileeducation/markr/entity/Test.java @@ -10,71 +10,74 @@ import java.util.Set; @Table(name = "tests") public class Test { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "test_id", nullable = false, unique = true) - private String testId; - - @Column(name = "marks_available", nullable = false) - private Integer marksAvailable; - - @OneToMany(mappedBy = "test", cascade = CascadeType.ALL, orphanRemoval = true) - private Set<TestResult> testResults = new HashSet<>(); - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTestId() { - return testId; - } - - public void setTestId(String testId) { - this.testId = testId; - } - - public Integer getMarksAvailable() { - return marksAvailable; - } - - public void setMarksAvailable(Integer marksAvailable) { - this.marksAvailable = marksAvailable; - } - - public Set<TestResult> getTestResults() { - return testResults; - } - - public void setTestResults(Set<TestResult> testResults) { - this.testResults = testResults; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Test test = (Test) o; - return Objects.equals(id, test.id) && Objects.equals(testId, test.testId) && Objects.equals(marksAvailable, test.marksAvailable) && Objects.equals(testResults, test.testResults); - } - - @Override - public int hashCode() { - return Objects.hash(id, testId, marksAvailable, testResults); - } - - @Override - public String toString() { - return "Test{" + - "id=" + id + - ", testId='" + testId + '\'' + - ", marksAvailable=" + marksAvailable + - ", testResults=" + testResults + - '}'; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "test_id", nullable = false, unique = true) + private String testId; + + @Column(name = "marks_available", nullable = false) + private Integer marksAvailable; + + @OneToMany(mappedBy = "test", cascade = CascadeType.ALL, orphanRemoval = true) + private Set<TestResult> testResults = new HashSet<>(); + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTestId() { + return testId; + } + + public void setTestId(String testId) { + this.testId = testId; + } + + public Integer getMarksAvailable() { + return marksAvailable; + } + + public void setMarksAvailable(Integer marksAvailable) { + this.marksAvailable = marksAvailable; + } + + public Set<TestResult> getTestResults() { + return testResults; + } + + public void setTestResults(Set<TestResult> testResults) { + this.testResults = testResults; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Test test = (Test) o; + return Objects.equals(id, test.id) && + Objects.equals(testId, test.testId) && + Objects.equals(marksAvailable, test.marksAvailable) && + Objects.equals(testResults, test.testResults); + } + + @Override + public int hashCode() { + return Objects.hash(id, testId, marksAvailable, testResults); + } + + @Override + public String toString() { + return "Test{" + + "id=" + id + + ", testId='" + testId + '\'' + + ", marksAvailable=" + marksAvailable + + ", testResults=" + testResults + + '}'; + } } diff --git a/src/main/java/com/stileeducation/markr/entity/TestResult.java b/src/main/java/com/stileeducation/markr/entity/TestResult.java index 0d68f62..26b2346 100644 --- a/src/main/java/com/stileeducation/markr/entity/TestResult.java +++ b/src/main/java/com/stileeducation/markr/entity/TestResult.java @@ -8,83 +8,83 @@ import java.util.Objects; @Table(name = "test_results") public class TestResult { - public TestResult() { - } - - public TestResult(Long id, Student student, Test test, Integer marksAwarded) { - this.id = id; - this.student = student; - this.test = test; - this.marksAwarded = marksAwarded; - } - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "student_id", nullable = false) - private Student student; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "test_id", nullable = false) - private Test test; - - @Column(name = "marks_awarded", nullable = false) - private Integer marksAwarded; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Student getStudent() { - return student; - } - - public void setStudent(Student student) { - this.student = student; - } - - public Test getTest() { - return test; - } - - public void setTest(Test test) { - this.test = test; - } - - public Integer getMarksAwarded() { - return marksAwarded; - } - - public void setMarksAwarded(Integer marksAwarded) { - this.marksAwarded = marksAwarded; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - TestResult that = (TestResult) o; - return Objects.equals(id, that.id) && Objects.equals(student, that.student) && Objects.equals(test, that.test) && Objects.equals(marksAwarded, that.marksAwarded); - } - - @Override - public int hashCode() { - return Objects.hash(id, student, test, marksAwarded); - } - - @Override - public String toString() { - return "TestResult{" + - "id=" + id + - ", student=" + student + - ", test=" + test + - ", marksAwarded=" + marksAwarded + - '}'; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "student_id", nullable = false) + private Student student; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "test_id", nullable = false) + private Test test; + @Column(name = "marks_awarded", nullable = false) + private Integer marksAwarded; + + public TestResult() { + } + + public TestResult(Long id, Student student, Test test, Integer marksAwarded) { + this.id = id; + this.student = student; + this.test = test; + this.marksAwarded = marksAwarded; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Student getStudent() { + return student; + } + + public void setStudent(Student student) { + this.student = student; + } + + public Test getTest() { + return test; + } + + public void setTest(Test test) { + this.test = test; + } + + public Integer getMarksAwarded() { + return marksAwarded; + } + + public void setMarksAwarded(Integer marksAwarded) { + this.marksAwarded = marksAwarded; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + TestResult that = (TestResult) o; + return Objects.equals(id, that.id) && + Objects.equals(student, that.student) && + Objects.equals(test, that.test) && + Objects.equals(marksAwarded, that.marksAwarded); + } + + @Override + public int hashCode() { + return Objects.hash(id, student, test, marksAwarded); + } + + @Override + public String toString() { + return "TestResult{" + + "id=" + id + + ", student=" + student + + ", test=" + test + + ", marksAwarded=" + marksAwarded + + '}'; + } }
\ No newline at end of file |
