main
Last change
on this file since 5b447b0 was 5b447b0, checked in by Test <matonikolov77@…>, 2 years ago |
Adding models and resources
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[5b447b0] | 1 | package com.wediscussmovies.project.model.relation;
|
---|
| 2 |
|
---|
| 3 | import com.wediscussmovies.project.model.Person;
|
---|
| 4 | import com.wediscussmovies.project.model.User;
|
---|
| 5 | import com.wediscussmovies.project.model.primarykeys.PersonRatesPK;
|
---|
| 6 | import lombok.Data;
|
---|
| 7 |
|
---|
| 8 | import javax.persistence.*;
|
---|
| 9 | import java.util.Objects;
|
---|
| 10 |
|
---|
| 11 | @Entity
|
---|
| 12 | @Table(name = "person_rates", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
|
---|
| 13 | @Data
|
---|
| 14 | public class PersonRates {
|
---|
| 15 |
|
---|
| 16 | @EmbeddedId
|
---|
| 17 | private PersonRatesPK id;
|
---|
| 18 |
|
---|
| 19 | @Basic
|
---|
| 20 | @Column(name = "reason")
|
---|
| 21 | private String reason;
|
---|
| 22 | @Basic
|
---|
| 23 | @Column(name = "stars_rated")
|
---|
| 24 | private int starsRated;
|
---|
| 25 |
|
---|
| 26 |
|
---|
| 27 | @ManyToOne
|
---|
| 28 | @JoinColumn(name = "person_id")
|
---|
| 29 | @MapsId("person_id")
|
---|
| 30 | private Person person;
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | @ManyToOne
|
---|
| 34 | @JoinColumn(name = "user_id")
|
---|
| 35 | @MapsId("user_id")
|
---|
| 36 | private User user;
|
---|
| 37 |
|
---|
| 38 |
|
---|
| 39 | public PersonRates() {
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public PersonRates(User user, Person person, String reason, Integer starsRated) {
|
---|
| 43 | this.id = new PersonRatesPK(person.getPersonId(), user.getUserId());
|
---|
| 44 | this.reason = reason;
|
---|
| 45 | this.starsRated = starsRated;
|
---|
| 46 | this.person = person;
|
---|
| 47 | this.user = user;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | @Override
|
---|
| 51 | public boolean equals(Object o) {
|
---|
| 52 | if (this == o) return true;
|
---|
| 53 | if (o == null || getClass() != o.getClass()) return false;
|
---|
| 54 | PersonRates that = (PersonRates) o;
|
---|
| 55 | return Objects.equals(id, that.id);
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | @Override
|
---|
| 59 | public int hashCode() {
|
---|
| 60 | return Objects.hash(id);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.