-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.java
More file actions
94 lines (71 loc) · 2.03 KB
/
Post.java
File metadata and controls
94 lines (71 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package com.example.init.models;
import javax.persistence.*;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Set;
@Entity
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false)
private Long id;
@ManyToOne
@JoinColumn(name = "coder_id")
private Coders applicationUser;
private String body;
private String createdAt;
// @ManyToOne
// @JoinTable(name = "Comment", joinColumns = @JoinColumn(name = "post_id"), inverseJoinColumns = @JoinColumn(name = "comment_id"))
// Post post;
@OneToMany(mappedBy = "post" , fetch = FetchType.EAGER)
private List<Comment> comments;
// public Post(Post post, String body) {
// this.post = post;
// this.body = body;
// }
// public Post getPost() {
// return post;
// }
public Post() {
}
public Post(Coders applicationUser, String body) {
this.applicationUser = applicationUser;
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm");
this.createdAt = sdf.format(new Timestamp(System.currentTimeMillis()).getTime());
this.body = body;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Coders getApplicationUser() {
return applicationUser;
}
public void setApplicationUser(Coders applicationUser) {
this.applicationUser = applicationUser;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getCreatedAt() {
return createdAt;
}
public void setCreatedAt(String createdAt) {
this.createdAt = createdAt;
}
// public void setPost(Post post) {
// this.post = post;
// }
public List<Comment> getComments() {
return comments;
}
public void setComments(List<Comment> comments) {
this.comments = comments;
}
}