main
Last change
on this file since 2a5d6a3 was 2a5d6a3, checked in by Petar Partaloski <ppartaloski@…>, 2 years ago |
Controller, Repository and Service layer improvements, Entity updating
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[6e7b472] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
[7a0bf79] | 3 | import lombok.Data;
|
---|
| 4 |
|
---|
[6e7b472] | 5 | import javax.persistence.*;
|
---|
| 6 | import java.sql.Date;
|
---|
[2a5d6a3] | 7 | import java.util.Optional;
|
---|
[6e7b472] | 8 |
|
---|
[7a0bf79] | 9 | @Data
|
---|
[2a5d6a3] | 10 | @Entity
|
---|
| 11 | @Table(name="replies")
|
---|
[6e7b472] | 12 | public class Reply {
|
---|
| 13 | @Id
|
---|
| 14 | @GeneratedValue
|
---|
| 15 | @Column(name = "reply_id")
|
---|
| 16 | private int reply_id;
|
---|
| 17 |
|
---|
| 18 | @ManyToOne
|
---|
| 19 | @Column(name = "discussion_id")
|
---|
| 20 | private Discussion discussion;
|
---|
| 21 |
|
---|
| 22 | @ManyToOne
|
---|
| 23 | @Column(name = "user_id")
|
---|
| 24 | private User user;
|
---|
| 25 |
|
---|
| 26 | @Column(name = "date", nullable = false)
|
---|
| 27 | private Date date;
|
---|
| 28 |
|
---|
| 29 | @Column(name= "text", length = 1000, nullable = false)
|
---|
| 30 | private String text;
|
---|
[2a5d6a3] | 31 |
|
---|
| 32 | public Reply(Discussion discussion, User user, Date date, String text) {
|
---|
| 33 | this.discussion = discussion;
|
---|
| 34 | this.user = user;
|
---|
| 35 | this.date = date;
|
---|
| 36 | this.text = text;
|
---|
| 37 | }
|
---|
[6e7b472] | 38 | }
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | /*
|
---|
| 42 |
|
---|
| 43 | create table replies(
|
---|
| 44 | discussion_id integer,
|
---|
| 45 | reply_id serial,
|
---|
| 46 | text varchar(1000) not null,
|
---|
| 47 | date date not null,
|
---|
| 48 | user_id integer not null,
|
---|
| 49 | constraint pk_replies primary key(discussion_id,reply_id),
|
---|
| 50 | constraint fk_user_create_reply foreign key (user_id) references users(user_id)
|
---|
| 51 | on delete cascade on update cascade,
|
---|
| 52 | constraint fk_reply_discussion foreign key (discussion_id) references discussions(discussion_id)
|
---|
| 53 | on delete cascade on update cascade
|
---|
| 54 |
|
---|
| 55 |
|
---|
| 56 | );
|
---|
| 57 | */ |
---|
Note:
See
TracBrowser
for help on using the repository browser.