content: package io.amplicode.blog.model;
  
  import jakarta.persistence.*;
  
  import java.time.Instant;
  import java.util.LinkedHashSet;
  import java.util.Set;
  
  @Entity
  @Table(name = "posts")
  public class Post extends BaseEntity {
      @Column(name = "title", nullable = false)
      private String title;
  
      @Lob
      @Column(name = "text", nullable = false)
      private String text;
  
      @Column(name = "published_at")
      private Instant publishedAt;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "author_id", nullable = false)
      private User author;
  
      @ManyToMany
      @JoinTable(name = "posts_comments",
              joinColumns = @JoinColumn(name = "post_id"),
              inverseJoinColumns = @JoinColumn(name = "comments_id"))
      private Set<Comment> comments = new LinkedHashSet<>();
  
      public Set<Comment> getComments() {
          return comments;
      }
  
      public void setComments(Set<Comment> comments) {
          this.comments = comments;
      }
  
      public String getTitle() {
          return title;
      }
  
      public void setTitle(String title) {
          this.title = title;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
      public Instant getPublishedAt() {
          return publishedAt;
      }
  
      public void setPublishedAt(Instant publishedAt) {
          this.publishedAt = publishedAt;
      }
  
      public User getAuthor() {
          return author;
      }
  
      public void setAuthor(User author) {
          this.author = author;
      }
  
  }