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