Skip to content

Commit

Permalink
Comment.java
Browse files Browse the repository at this point in the history
  • Loading branch information
VladSlob authored Aug 1, 2024
1 parent 082179c commit 955c577
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/java/core/basesyntax/model/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
import java.util.List;

@Entity
Expand All @@ -17,6 +18,10 @@ public class Comment {
private Long id;
private String content;

@ManyToOne
@JoinColumn(name = "user_id")
private User user;

@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinTable(
name = "comment_smile",
Expand All @@ -25,7 +30,6 @@ public class Comment {
)
private List<Smile> smiles;

// getters and setters
public Long getId() {
return id;
}
Expand All @@ -42,6 +46,14 @@ public void setContent(String content) {
this.content = content;
}

public User getUser() {
return user;
}

public void setUser(User user) {
this.user = user;
}

public List<Smile> getSmiles() {
return smiles;
}
Expand Down

0 comments on commit 955c577

Please sign in to comment.