1 | package com.wediscussmovies.project.model;
|
---|
2 |
|
---|
3 | import com.wediscussmovies.project.model.relation.MovieLikes;
|
---|
4 | import com.wediscussmovies.project.model.relation.MovieActors;
|
---|
5 | import com.wediscussmovies.project.model.relation.MovieGenres;
|
---|
6 | import com.wediscussmovies.project.model.relation.MovieRates;
|
---|
7 | import lombok.Data;
|
---|
8 |
|
---|
9 | import javax.persistence.*;
|
---|
10 | import java.sql.Date;
|
---|
11 | import java.util.Collection;
|
---|
12 | import java.util.Comparator;
|
---|
13 | import java.util.Objects;
|
---|
14 |
|
---|
15 | @Entity
|
---|
16 | @Table(name = "movies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
|
---|
17 | @Data
|
---|
18 | public class Movie {
|
---|
19 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
20 | @Id
|
---|
21 | @Column(name = "movie_id")
|
---|
22 | private int movieId;
|
---|
23 | @Basic
|
---|
24 | @Column(name = "title")
|
---|
25 | private String title;
|
---|
26 | @Basic
|
---|
27 | @Column(name = "description")
|
---|
28 | private String description;
|
---|
29 | @Basic
|
---|
30 | @Column(name = "image_url")
|
---|
31 | private String imageUrl;
|
---|
32 | @Basic
|
---|
33 | @Column(name = "airing_date")
|
---|
34 | private Date airingDate;
|
---|
35 | @Basic
|
---|
36 | @Column(name = "imdb_rating")
|
---|
37 | private Double imdbRating;
|
---|
38 |
|
---|
39 | @OneToMany(mappedBy = "movie")
|
---|
40 | private Collection<MovieActors> actors;
|
---|
41 | @OneToMany(mappedBy = "movie")
|
---|
42 | private Collection<MovieGenres> genres;
|
---|
43 | @OneToMany(mappedBy = "movie")
|
---|
44 | private Collection<MovieLikes> likes;
|
---|
45 | @OneToMany(mappedBy = "movie")
|
---|
46 | private Collection<MovieRates> rates;
|
---|
47 |
|
---|
48 | @ManyToOne
|
---|
49 | @JoinColumn(name = "director_id")
|
---|
50 | private Person director;
|
---|
51 |
|
---|
52 | public Movie() {
|
---|
53 |
|
---|
54 | }
|
---|
55 |
|
---|
56 | public Movie(String title, String description, String imageUrl, Date airingDate,
|
---|
57 | Double imdbRating, Person director) {
|
---|
58 | this.title = title;
|
---|
59 | this.description = description;
|
---|
60 | this.imageUrl = imageUrl;
|
---|
61 | this.airingDate = airingDate;
|
---|
62 | this.imdbRating = imdbRating;
|
---|
63 | this.director = director;
|
---|
64 |
|
---|
65 | }
|
---|
66 |
|
---|
67 | @Override
|
---|
68 | public boolean equals(Object o) {
|
---|
69 | if (this == o) return true;
|
---|
70 | if (o == null || getClass() != o.getClass()) return false;
|
---|
71 | Movie movie = (Movie) o;
|
---|
72 | return movieId == movie.movieId;
|
---|
73 | }
|
---|
74 |
|
---|
75 | @Override
|
---|
76 | public int hashCode() {
|
---|
77 | return Objects.hash(movieId);
|
---|
78 | }
|
---|
79 |
|
---|
80 | public static Comparator<Movie> comparatorTitle = Comparator.comparing(Movie::getTitle);
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 | }
|
---|