content: package com.bookstore.entity;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  import javax.persistence.CascadeType;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import javax.persistence.IdClass;
  import javax.persistence.OneToMany;
  import org.hibernate.annotations.GenericGenerator;
  import org.hibernate.annotations.Parameter;
  
  @Entity
  @IdClass(AuthorId.class)
  public class Author implements Serializable {
  
      private static final long serialVersionUID = 1L;
      
      @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "hilo")
      @GenericGenerator(name = "hilo", strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
              parameters = {
                  @Parameter(name = "sequence_name", value = "hilo_sequence"),
                  @Parameter(name = "initial_value", value = "1"),
                  @Parameter(name = "increment_size", value = "100"),
                  @Parameter(name = "optimizer", value = "hilo")
              }
      )
      private Long authorId;
      
      @Id
      private String name;
      
      private int age;
      private String genre;
          
      @OneToMany(cascade = CascadeType.ALL,
              mappedBy = "author", orphanRemoval = true)
      private List<Book> books = new ArrayList<>();
  
      public void addBook(Book book) {
          this.books.add(book);
          book.setAuthor(this);
      }
  
      public void removeBook(Book book) {
          book.setAuthor(null);
          this.books.remove(book);
      }
  
      public void removeBooks() {
          Iterator<Book> iterator = this.books.iterator();
  
          while (iterator.hasNext()) {
              Book book = iterator.next();
  
              book.setAuthor(null);
              iterator.remove();
          }
      }
      
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public Long getAuthorId() {
          return authorId;
      }
  
      public void setAuthorId(Long authorId) {
          this.authorId = authorId;
      }
          
      public int getAge() {
          return age;
      }
  
      public void setAge(int age) {
          this.age = age;
      }
      
      public String getGenre() {
          return genre;
      }
  
      public void setGenre(String genre) {
          this.genre = genre;
      }
  
      public List<Book> getBooks() {
          return books;
      }
  
      public void setBooks(List<Book> books) {
          this.books = books;
      }
  
      @Override
      public String toString() {
          return "Author{" + "name=" + name + ", authorId=" + authorId + 
                  ", age=" + age + ", genre=" + genre + ", books=" + books + '}';
      }
  
  }