source: Git/src/main/java/com/wediscussmovies/project/model/Movie.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: 2.2 KB
Line 
1package com.wediscussmovies.project.model;
2
3import com.wediscussmovies.project.model.relation.MovieLikes;
4import com.wediscussmovies.project.model.relation.MovieActors;
5import com.wediscussmovies.project.model.relation.MovieGenres;
6import com.wediscussmovies.project.model.relation.MovieRates;
7import lombok.Data;
8
9import javax.persistence.*;
10import java.sql.Date;
11import java.util.Collection;
12import java.util.Comparator;
13import java.util.Objects;
14
15@Entity
16@Table(name = "movies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
17@Data
18public 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}
Note: See TracBrowser for help on using the repository browser.