content: package com.bookstore.entity;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.OneToMany;
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  
  @Entity
  public class Author implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      private String name;
      private String genre;
      private int age;
  
      @OneToMany(mappedBy = "author",
              cascade = CascadeType.ALL, orphanRemoval = true)
      private List<AuthorBook> books = new ArrayList<>();
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getGenre() {
          return genre;
      }
  
      public void setGenre(String genre) {
          this.genre = genre;
      }
  
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
  
      public List<AuthorBook> getBooks() {
          return books;
      }
  
      public void setBooks(List<AuthorBook> books) {
          this.books = books;
      }
  
      @Override
      public boolean equals(Object obj) {
          if (obj == null) {
              return false;
          }
          if (this == obj) {
              return true;
          }
          if (getClass() != obj.getClass()) {
              return false;
          }
  
          return id != null && id.equals(((Author) obj).id);
      }
  
      @Override
      public int hashCode() {
          return 2021;
      }
  
      @Override
      public String toString() {
          return "Author{" +
                  "id=" + id +
                  ", name='" + name + '\'' +
                  ", genre='" + genre + '\'' +
                  ", age=" + age +
                  ", books=" + books +
                  '}';
      }
  }