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 TeacherSubjectRelationID implements Serializable {
|
---|
14 | private static final long serialVersionUID = -3195641753836744763L;
|
---|
15 | @Column(name = "id_nastavnik", nullable = false)
|
---|
16 | private Integer teacherID;
|
---|
17 | @Column(name = "id_predmet", nullable = false)
|
---|
18 | private Integer subjectID;
|
---|
19 |
|
---|
20 | public TeacherSubjectRelationID(Integer teacherID, Integer subjectID) {
|
---|
21 | this.teacherID = teacherID;
|
---|
22 | this.subjectID = subjectID;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public TeacherSubjectRelationID() {
|
---|
26 |
|
---|
27 | }
|
---|
28 |
|
---|
29 | @Override
|
---|
30 | public int hashCode() {
|
---|
31 | return Objects.hash(subjectID, teacherID);
|
---|
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 | TeacherSubjectRelationID entity = (TeacherSubjectRelationID) o;
|
---|
39 | return Objects.equals(this.subjectID, entity.subjectID) &&
|
---|
40 | Objects.equals(this.teacherID, entity.teacherID);
|
---|
41 | }
|
---|
42 | } |
---|