Skip to content

Instantly share code, notes, and snippets.

@tailorsmit
Created April 22, 2021 11:03
package com.simplecoding.social.model;
import javax.persistence.*;
import java.util.Date;
@Entity
@Table(name = "posts")
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "user_id",referencedColumnName = "id")
private User user;
@Column(columnDefinition="TEXT")
private String content;
@Column(name="createdDate", columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
private Date createdDate;
public Post() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment