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 InterestID implements Serializable {
|
---|
14 |
|
---|
15 | private static final long serialVersionUID = 1443493244068543984L;
|
---|
16 | @Column(name = "id_ucenik", nullable = false)
|
---|
17 | private Integer studentID;
|
---|
18 | @Column(name = "id_predmet", nullable = false)
|
---|
19 | private Integer subjectID;
|
---|
20 |
|
---|
21 | public InterestID(Integer subjectID, Integer ucenikId) {
|
---|
22 | this.subjectID = subjectID;
|
---|
23 | this.studentID = ucenikId;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public InterestID() {
|
---|
27 |
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public int hashCode() {
|
---|
32 | return Objects.hash(subjectID, studentID);
|
---|
33 | }
|
---|
34 |
|
---|
35 | @Override
|
---|
36 | public boolean equals(Object o) {
|
---|
37 | if (this == o) return true;
|
---|
38 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
39 | InterestID entity = (InterestID) o;
|
---|
40 | return Objects.equals(this.subjectID, entity.subjectID) &&
|
---|
41 | Objects.equals(this.studentID, entity.studentID);
|
---|
42 | }
|
---|
43 | } |
---|