[2d57cad] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
| 3 | import javax.persistence.*;
|
---|
| 4 |
|
---|
| 5 | @Entity
|
---|
| 6 | @Table(name = "movie_likes", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
|
---|
| 7 | @IdClass(MovieLikesEntityPK.class)
|
---|
| 8 | public class MovieLikesEntity {
|
---|
| 9 | @Id
|
---|
| 10 | @Column(name = "movie_id")
|
---|
| 11 | private int movieId;
|
---|
| 12 | @Id
|
---|
| 13 | @Column(name = "user_id")
|
---|
| 14 | private int userId;
|
---|
| 15 | @ManyToOne
|
---|
| 16 | @JoinColumn(name = "movie_id", referencedColumnName = "movie_id", nullable = false,insertable = false, updatable = false)
|
---|
| 17 | private Movie moviesByMovieId;
|
---|
| 18 | @ManyToOne
|
---|
| 19 | @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false,insertable = false, updatable = false)
|
---|
| 20 | private User usersByUserId;
|
---|
| 21 |
|
---|
| 22 | public int getMovieId() {
|
---|
| 23 | return movieId;
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public void setMovieId(int movieId) {
|
---|
| 27 | this.movieId = movieId;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | public int getUserId() {
|
---|
| 31 | return userId;
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | public void setUserId(int userId) {
|
---|
| 35 | this.userId = userId;
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | @Override
|
---|
| 39 | public boolean equals(Object o) {
|
---|
| 40 | if (this == o) return true;
|
---|
| 41 | if (o == null || getClass() != o.getClass()) return false;
|
---|
| 42 |
|
---|
| 43 | MovieLikesEntity that = (MovieLikesEntity) o;
|
---|
| 44 |
|
---|
| 45 | if (movieId != that.movieId) return false;
|
---|
| 46 | if (userId != that.userId) return false;
|
---|
| 47 |
|
---|
| 48 | return true;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | @Override
|
---|
| 52 | public int hashCode() {
|
---|
| 53 | int result = movieId;
|
---|
| 54 | result = 31 * result + userId;
|
---|
| 55 | return result;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | public Movie getMoviesByMovieId() {
|
---|
| 59 | return moviesByMovieId;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | public void setMoviesByMovieId(Movie moviesByMovieId) {
|
---|
| 63 | this.moviesByMovieId = moviesByMovieId;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 | public User getUsersByUserId() {
|
---|
| 67 | return usersByUserId;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | public void setUsersByUserId(User usersByUserId) {
|
---|
| 71 | this.usersByUserId = usersByUserId;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|