source: Git/src/main/java/com/wediscussmovies/project/model/Movie.java@ f25e8dd

main
Last change on this file since f25e8dd was f25e8dd, checked in by Petar Partaloski <ppartaloski@…>, 2 years ago

Fixed and added a better front end, improved clarity

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