summaryrefslogtreecommitdiff
path: root/src/main/java/com/stileeducation/markr/entity/TestResult.java
blob: 26b234609ea65e9de53b69c46375d95fbc00393a (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
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;

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