source: Git/src/main/java/com/wediscussmovies/project/model/Discussion.java@ 7a0bf79

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

Early implementations, MovieController CRUD implementation included

  • Property mode set to 100644
File size: 1.6 KB
Line 
1package com.wediscussmovies.project.model;
2
3import lombok.Data;
4
5import javax.persistence.*;
6import java.sql.Date;
7import java.util.List;
8
9@Data
10@Entity
11public 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 */
Note: See TracBrowser for help on using the repository browser.