com/wpollock/jpademo/Book.java
/* Java SE JPA demo, using EclipseLink and embedded JavaDB
* @author Wayne Pollock, Tampa Florida USA
*
* Note the use of JPA annotations to define the primary key and
* have its value auto-generated. Constraints on other columns
* are defined using the @Column annotation. There are many more
* annotations to override any JPA defaults and control behavior;
* this is indeed a trivial example.
*/
package com.wpollock.jpademo;
import jakarta.persistence.*;
@Entity
public class Book {
@Id @GeneratedValue
private int id;
private String title;
@Column (length = 1024 ) // Max num of characters
private String description;
@Column( nullable = false ) // NOT NULL
private String isbn;
private Float price;
private String author;
public Book () { // A no-arg constructor is required and used by JPA.
}
public int getId () { return id; } // Read-only; no "set" method.
public String getTitle () { return title; }
public void setTitle ( String title ) { this.title = title; }
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 Float getPrice () { return price; }
public void setPrice ( Float price ) { this.price = price; }
public String getAuthor () { return author; }
public void setAuthor ( String author ) { this.author = author; }
}