source: Git/src/main/java/com/wediscussmovies/project/model/relation/MovieActors.java@ 5b447b0

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.2 KB
Line 
1package com.wediscussmovies.project.model.relation;
2
3import com.wediscussmovies.project.model.Movie;
4import com.wediscussmovies.project.model.Person;
5import com.wediscussmovies.project.model.primarykeys.MovieActorsPK;
6import lombok.Data;
7
8import javax.persistence.*;
9import java.util.Objects;
10
11@Entity
12@Table(name = "movie_actors", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
13@Data
14public 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.