SHARE
TWEET

Untitled

a guest Jun 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Entity
  2. public class Post implements Serializable {
  3.  
  4.     private static final long serialVersionUID = 1L;
  5.     @Id
  6.     @GeneratedValue(strategy = GenerationType.AUTO)
  7.     @Column(updatable = false, nullable = false)
  8.     private Long id;
  9.     private String name;
  10.  
  11.     @Column(columnDefinition = "text")
  12.     private String caption;
  13.     private String location;
  14.     private int likes;
  15.     private Date postedDate;
  16.     private String username;
  17.     private Long userImageId;
  18.  
  19.     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  20.     @JoinColumn(name = "post_id")
  21.     private List<Comment> commentsList;
  22.     public Post() {
  23.  
  24.     }
  25.  
  26. }
  27.      
  28. @Entity
  29. public class User implements Serializable {
  30.  
  31.     private static final long serialVersionUID = 1L;
  32.     @Id
  33.     @GeneratedValue(strategy = GenerationType.AUTO)
  34.     @Column(updatable = false, nullable = false)
  35.     private Long id;
  36.     private String name;
  37.  
  38.     @Column(unique = true)
  39.     private String username;
  40.     @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
  41.     private String password;
  42.     private String email;
  43.  
  44.     @Column(columnDefinition = "text")
  45.     private String bio;
  46.  
  47.     @CreationTimestamp
  48.     private Date createdDate;
  49.  
  50.     @OneToMany(mappedBy = "appUser", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  51.     private Set<UserRole> userRoles = new HashSet<>();
  52.  
  53.     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  54.     private List<Post> post;
  55.  
  56.     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
  57.     private List<Post> likedPost;
  58.  
  59.     public User() {
  60.     }
  61.  
  62. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top