[6e7b472] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
[7a0bf79] | 3 | import lombok.Data;
|
---|
| 4 |
|
---|
[6e7b472] | 5 | import javax.persistence.*;
|
---|
| 6 | import java.sql.Date;
|
---|
| 7 | import java.util.List;
|
---|
| 8 |
|
---|
[7a0bf79] | 9 | @Data
|
---|
[6e7b472] | 10 | @Entity
|
---|
| 11 | public class Discussion {
|
---|
| 12 | @Id
|
---|
| 13 | @GeneratedValue
|
---|
| 14 | private int discussion_id;
|
---|
| 15 |
|
---|
| 16 | @ManyToOne
|
---|
| 17 | @Column(name = "movie_id")
|
---|
| 18 | private Movie movie;
|
---|
| 19 |
|
---|
| 20 | @ManyToOne()
|
---|
| 21 | @Column(name = "person_id")
|
---|
| 22 | private Person person;
|
---|
| 23 |
|
---|
| 24 | @ManyToOne
|
---|
| 25 | @Column(name = "user_id")
|
---|
| 26 | private User user;
|
---|
| 27 |
|
---|
| 28 | @Column(name = "text", length = 1000, nullable = false)
|
---|
| 29 | private String text;
|
---|
| 30 |
|
---|
| 31 | @Column(name = "title", length = 1000, nullable = false)
|
---|
| 32 | private String title;
|
---|
| 33 |
|
---|
| 34 | @Column(name = "date", nullable = false)
|
---|
| 35 | private Date date;
|
---|
| 36 |
|
---|
| 37 | @OneToMany
|
---|
| 38 | private List<Reply> replies;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | /*
|
---|
| 43 | create table discussions(
|
---|
| 44 | discussion_id serial primary key,
|
---|
| 45 | type char(1) not null,
|
---|
| 46 | text varchar(1000) not null,
|
---|
| 47 | title varchar(250) not null,
|
---|
| 48 | date date not null,
|
---|
| 49 | user_id integer not null,
|
---|
| 50 | movie_id integer,
|
---|
| 51 | person_id integer,
|
---|
| 52 | constraint fk_user_created foreign key (user_id) references users(user_id)
|
---|
| 53 | on delete cascade on update cascade,
|
---|
| 54 | constraint ck_type_discussion check( (type = 'M' and movie_id notnull and person_id isnull)
|
---|
| 55 | or (type='P' and person_id notnull and movie_id isnull)),
|
---|
| 56 | constraint fk_discussion_movie foreign key (movie_id) references movies(movie_id)
|
---|
| 57 | on delete cascade on update cascade,
|
---|
| 58 | constraint fk_discussion_person foreign key (person_id) references persons(person_id)
|
---|
| 59 | on delete cascade on update cascade
|
---|
| 60 | );
|
---|
| 61 |
|
---|
| 62 | */ |
---|