content: package com.bookstore.entity;
  
  import java.io.Serializable;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  import org.hibernate.annotations.GenericGenerator;
  import org.hibernate.annotations.Parameter;
  
  @Entity
  public class Author implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      // This will disable insert batching - AVOID IT!
      // @GeneratedValue(strategy = GenerationType.IDENTITY)
  
      // This will work, but better use the below solution to reduce database roundtrips
      // @GeneratedValue(strategy = GenerationType.AUTO)
      
      // This will allow insert batching and optimizes the identifiers
      // generation via the hi/lo algorithm which generated in-memory identifiers   
      @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 = "10"),
                  @Parameter(name = "optimizer", value = "hilo")
              })
      private Long id;
  
      private int age;
      private String name;
      private String genre;
  
      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;
      }
  
      @Override
      public String toString() {
          return "Author{" + "id=" + id + ", age=" + age
                  + ", name=" + name + ", genre=" + genre + '}';
      }
  }
  