Spaces:
Sleeping
Sleeping
File size: 1,159 Bytes
bb5169d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
package com.krishna.model;
import jakarta.persistence.*;
import java.util.UUID;
@Entity
@Table(name = "comments")
public class CommentModel {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
private String content;
@ManyToOne
@JoinColumn(name = "user_id", nullable = false)
private UserModel user;
@ManyToOne
@JoinColumn(name = "post_id", nullable = false)
private PostModel post;
// Constructors
public CommentModel() {}
public CommentModel(String content, UserModel user, PostModel post) {
this.content = content;
this.user = user;
this.post = post;
}
// Getters and Setters
public Long getId() { return id; }
public void setId(Long id) { this.id = id; }
public String getContent() { return content; }
public void setContent(String content) { this.content = content; }
public UserModel getUser() { return user; }
public void setUser(UserModel user) { this.user = user; }
public PostModel getPost() { return post; }
public void setPost(PostModel post) { this.post = post; }
}
|