Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Andras Madi-Szabo
Added: May 13, 2020 9:51 AM
Views: 126
Tags: no tags
  1. import java.util.Date;
  2. import javax.persistence.Entity;
  3. import javax.persistence.FetchType;
  4. import javax.persistence.GeneratedValue;
  5. import javax.persistence.Id;
  6. import javax.persistence.JoinColumn;
  7. import javax.persistence.ManyToOne;
  8. import lombok.Getter;
  9. import lombok.Setter;
  10.  
  11. @Getter
  12. @Setter
  13.  
  14. public class Post {
  15.  
  16.   @Id
  17.   @GeneratedValue
  18.   private long id;
  19.   private Integer counter = 0;
  20.   private String url;
  21.   private String title;
  22.   private Date date;
  23.   @ManyToOne(fetch = FetchType.EAGER)
  24.   @JoinColumn
  25.   private PostUser postUser;
  26.  
  27.   public Post() {
  28.     this.date = new Date();
  29.   }
  30.  
  31.   public Post(String title, String url) {
  32.     this.title = title;
  33.     this.url = url;
  34.     this.date = new Date();
  35.   }
  36.  
  37. }