Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- public class Post implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(updatable = false, nullable = false)
- private Long id;
- private String name;
- @Column(columnDefinition = "text")
- private String caption;
- private String location;
- private int likes;
- private Date postedDate;
- private String username;
- private Long userImageId;
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- @JoinColumn(name = "post_id")
- private List<Comment> commentsList;
- public Post() {
- }
- }
- @Entity
- public class User implements Serializable {
- private static final long serialVersionUID = 1L;
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- @Column(updatable = false, nullable = false)
- private Long id;
- private String name;
- @Column(unique = true)
- private String username;
- @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
- private String password;
- private String email;
- @Column(columnDefinition = "text")
- private String bio;
- @CreationTimestamp
- private Date createdDate;
- @OneToMany(mappedBy = "appUser", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private Set<UserRole> userRoles = new HashSet<>();
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
- private List<Post> post;
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
- private List<Post> likedPost;
- public User() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement