The first step is to create a Java POJO class. We consider a simple class Book as follows:
//Book.java public class Book { private int b_id; private int b_price;
private String b_title; public Book(){}
public Book(String t, int p) {
this.b_title = t; this.b_price = p;
}
public int getId() { return b_id; }
public void setId(int id ) { this.b_id = id; }
public String getTitle() { return b_title; }
public void setTitle(String t ){ this.b_title = t; }
public int getPrice() { return b_price; }
}
public void setPrice(int p ) { this.b_price = p; }
This contains three private fields b_id, b_price and b_title and get and set methods for these fields. The b_id field works like an index, whereas b_titie and b_price fields store the title and price of a book respectively. It is a good idea to write a class in hibernate as JavaBeans compliant class.
Source: Uttam Kumar Roy (2015), Advanced Java programming, Oxford University Press.