[6e7b472] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
| 3 | import javax.persistence.*;
|
---|
| 4 | import java.sql.Date;
|
---|
| 5 | import java.util.List;
|
---|
| 6 |
|
---|
| 7 | @Entity(name="movies")
|
---|
| 8 | public class Movie {
|
---|
| 9 | @Id
|
---|
| 10 | @GeneratedValue
|
---|
| 11 | @Column(name="movie_id", nullable = false)
|
---|
| 12 | private int movie_id;
|
---|
| 13 |
|
---|
| 14 | @Column(name="title", length = 150, unique = true, nullable = false)
|
---|
| 15 | private String Title;
|
---|
| 16 |
|
---|
| 17 | @Column(name="description", nullable = false, length = 1000)
|
---|
| 18 | private String description;
|
---|
| 19 |
|
---|
| 20 | @Column(name="image_url", length = 300, nullable = false)
|
---|
| 21 | private String image_url;
|
---|
| 22 |
|
---|
| 23 | @Column(name="airing_date")
|
---|
| 24 | private Date airing_date;
|
---|
| 25 |
|
---|
| 26 | @Column(name="imdb_rating")
|
---|
| 27 | private float imdb_rating;
|
---|
| 28 |
|
---|
| 29 | @Column(name="director_id")
|
---|
| 30 | @ManyToOne
|
---|
| 31 | private Person director;
|
---|
| 32 |
|
---|
| 33 | @ManyToMany(mappedBy = "movie_actors")
|
---|
| 34 | private List<Person> actors;
|
---|
| 35 |
|
---|
| 36 | @ManyToMany(mappedBy = "movie_genres")
|
---|
| 37 | private List<Genre> genres;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | /*
|
---|
| 42 |
|
---|
| 43 | create table movies(
|
---|
| 44 | movie_id serial primary key,
|
---|
| 45 | title varchar(150) not null unique,
|
---|
| 46 | description varchar(1000) not null,
|
---|
| 47 | image_url varchar(300) not null,
|
---|
| 48 | airing_date date not null,
|
---|
| 49 | imdb_rating float,
|
---|
| 50 | director_id integer,
|
---|
| 51 | constraint fk_movie_director foreign key (director_id) references persons(person_id)
|
---|
| 52 | on delete cascade on update cascade,
|
---|
| 53 | constraint ck_person_is_director check( check_constraint_person(director_id) = 'D')
|
---|
| 54 | );
|
---|
| 55 | */ |
---|