summaryrefslogtreecommitdiff
path: root/src/main/java/com/stileeducation/markr/entity/TestResult.java
blob: bdbade4f2f2b08cb5fbf23d83ae3e3de7f337546 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.stileeducation.markr.entity;

import jakarta.persistence.*;

import java.util.Objects;

@Entity
@Table(name = "test_results")
public class TestResult {

  @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;

  @Transient
  private boolean created = false;

  @Transient
  private boolean updated = false;

  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;
  }

  public boolean isCreated() {
    return created;
  }

  public void setCreated(boolean created) {
    this.created = created;
  }

  public boolean isUpdated() {
    return updated;
  }

  public void setUpdated(boolean updated) {
    this.updated = updated;
  }

  @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) &&
        Objects.equals(created, that.created) &&
        Objects.equals(updated, that.updated);
  }

  @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 +
        ", created=" + created +
        ", updated=" + updated +
        '}';
  }
}