content: package io.amplicode.blog.model;
  
  import jakarta.persistence.*;
  import org.hibernate.proxy.HibernateProxy;
  
  import java.util.Objects;
  
  @Entity
  @Table(name = "comments")
  public class Comment extends BaseEntity {
      @Column(name = "text", nullable = false)
      private String text;
  
      @ManyToOne(fetch = FetchType.LAZY, optional = false)
      @JoinColumn(name = "author_id", nullable = false)
      private User author;
  
      public User getAuthor() {
          return author;
      }
  
      public void setAuthor(User author) {
          this.author = author;
      }
  
      public String getText() {
          return text;
      }
  
      public void setText(String text) {
          this.text = text;
      }
  
      @Override
      public final boolean equals(Object o) {
          if (this == o) return true;
          if (o == null) return false;
          Class<?> oEffectiveClass = o instanceof HibernateProxy
                  ? ((HibernateProxy) o).getHibernateLazyInitializer()
                  .getPersistentClass()
                  : o.getClass();
          Class<?> thisEffectiveClass = this instanceof HibernateProxy
                  ? ((HibernateProxy) this).getHibernateLazyInitializer()
                  .getPersistentClass()
                  : this.getClass();
          if (thisEffectiveClass != oEffectiveClass) return false;
          Comment comment = (Comment) o;
          return getId() != null && Objects.equals(getId(), comment.getId());
      }
  
      @Override
      public final int hashCode() {
          return this instanceof HibernateProxy
                  ? ((HibernateProxy) this).getHibernateLazyInitializer()
                  .getPersistentClass()
                  .hashCode()
                  : getClass().hashCode();
      }
  }