content: package org.agoncal.book.javaee7.chapter07.ex17;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.persistence.NamedQuery;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Size;
  
  import static org.agoncal.book.javaee7.chapter07.ex17.Book17.FIND_ALL;
  
  /**
   * @author Antonio Goncalves
   *         APress Book - Beginning Java EE 7 with Glassfish 4
   *         http://www.apress.com/
   *         http://www.antoniogoncalves.org
   *         --
   */
  @Entity
  @NamedQuery(name = FIND_ALL, query = "SELECT b FROM Book17 b")
  public class Book17 {
  
    // ======================================
    // =             Constants              =
    // ======================================
  
    public static final String FIND_ALL = "Book17.findAllBooks";
  
    // ======================================
    // =             Attributes             =
    // ======================================
  
    @Id
    @GeneratedValue
    private Long id;
    @NotNull
    private String title;
    private Float price;
    @Size(max = 2000)
    private String description;
    private String isbn;
    private Integer nbOfPage;
    private Boolean illustrations;
  
    // ======================================
    // =            Constructors            =
    // ======================================
  
    public Book17() {
    }
  
    public Book17(String title, Float price, String description, String isbn, Integer nbOfPage, Boolean illustrations) {
      this.title = title;
      this.price = price;
      this.description = description;
      this.isbn = isbn;
      this.nbOfPage = nbOfPage;
      this.illustrations = illustrations;
    }
  
    // ======================================
    // =          Getters & Setters         =
    // ======================================
  
    public Long getId() {
      return id;
    }
  
    public void setId(Long id) {
      this.id = id;
    }
  
    public String getTitle() {
      return title;
    }
  
    public void setTitle(String title) {
      this.title = title;
    }
  
    public Float getPrice() {
      return price;
    }
  
    public void setPrice(Float price) {
      this.price = price;
    }
  
    public String getDescription() {
      return description;
    }
  
    public void setDescription(String description) {
      this.description = description;
    }
  
    public String getIsbn() {
      return isbn;
    }
  
    public void setIsbn(String isbn) {
      this.isbn = isbn;
    }
  
    public Integer getNbOfPage() {
      return nbOfPage;
    }
  
    public void setNbOfPage(Integer nbOfPage) {
      this.nbOfPage = nbOfPage;
    }
  
    public Boolean getIllustrations() {
      return illustrations;
    }
  
    public void setIllustrations(Boolean illustrations) {
      this.illustrations = illustrations;
    }
  
    // ======================================
    // =         hash, equals, toString     =
    // ======================================
  
    @Override
    public String toString() {
      final StringBuilder sb = new StringBuilder();
      sb.append("Book17");
      sb.append("{id=").append(id);
      sb.append(", title='").append(title).append('\'');
      sb.append(", price=").append(price);
      sb.append(", description='").append(description).append('\'');
      sb.append(", isbn='").append(isbn).append('\'');
      sb.append(", nbOfPage=").append(nbOfPage);
      sb.append(", illustrations=").append(illustrations);
      sb.append('}');
      return sb.toString();
    }
  }