Created
April 5, 2016 09:59
-
-
Save AndySun25/a745b4fb90df4c0480420bc718b8688e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models; | |
import javax.persistence.*; | |
import java.sql.Timestamp; | |
import java.util.Collection; | |
@Entity | |
@Table(name = "post") | |
public class Post { | |
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) | |
@Column(name = "id") | |
private int id; | |
@OneToOne | |
@JoinColumn(name = "user_id") | |
private User user; | |
@Column(name = "title") | |
private String title; | |
@Column(name = "content") | |
private String content; | |
@Column(name = "created_at", insertable=false, updatable = false) | |
private Timestamp created_at; | |
@Column(name = "view_count") | |
private int view_count; | |
@ManyToMany(targetEntity = Tag.class) | |
@JoinTable( | |
name = "post_has_tags", | |
joinColumns=@JoinColumn(name = "post_id"), | |
inverseJoinColumns=@JoinColumn(name = "tag_id") | |
) | |
private Collection tags; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment