1 | package project.educatum.model.primarykeys;
|
---|
2 |
|
---|
3 | import lombok.Data;
|
---|
4 | import org.hibernate.Hibernate;
|
---|
5 |
|
---|
6 | import javax.persistence.Column;
|
---|
7 | import javax.persistence.Embeddable;
|
---|
8 | import java.io.Serializable;
|
---|
9 | import java.util.Objects;
|
---|
10 |
|
---|
11 | @Data
|
---|
12 | @Embeddable
|
---|
13 | public class TeacherStudentRelationID implements Serializable {
|
---|
14 |
|
---|
15 | public TeacherStudentRelationID(Integer teacherID, Integer studentID) {
|
---|
16 | this.teacherID = teacherID;
|
---|
17 | this.studentID = studentID;
|
---|
18 | }
|
---|
19 |
|
---|
20 | private static final long serialVersionUID = -3956016538071516037L;
|
---|
21 | @Column(name = "id_nastavnik", nullable = false)
|
---|
22 | private Integer teacherID;
|
---|
23 | @Column(name = "id_ucenik", nullable = false)
|
---|
24 | private Integer studentID;
|
---|
25 |
|
---|
26 | public TeacherStudentRelationID() {
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public int hashCode() {
|
---|
31 | return Objects.hash(teacherID, studentID);
|
---|
32 | }
|
---|
33 |
|
---|
34 | @Override
|
---|
35 | public boolean equals(Object o) {
|
---|
36 | if (this == o) return true;
|
---|
37 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
38 | TeacherStudentRelationID entity = (TeacherStudentRelationID) o;
|
---|
39 | return Objects.equals(this.teacherID, entity.teacherID) &&
|
---|
40 | Objects.equals(this.studentID, entity.studentID);
|
---|
41 | }
|
---|
42 | } |
---|