source: Git/src/main/java/com/wediscussmovies/project/model/Discussion.java@ 6e7b472

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

Initial commit, barebones setup

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