728x90 AdSpace

Saturday, 17 June 2017

Hibernate Persistent Class

Hibernate Persistent / Entity Class 

  1. This class uses standard JavaBean naming conventions for property getter and setter methods, as well as private visibility for the fields. Although this is the recommended design, it is not required.
  2. The no-argument constructor, which is also a JavaBean convention, is a requirement for all persistent classes. Hibernate will create objects for you, using Java Reflection. The constructor can be private. However, package or public visibility is required for runtime proxy generation and efficient data retrieval without bytecode instrumentation.
The entire concept of Hibernate is to take the values from Java class attributes and persist them to a database table. A mapping document helps Hibernate in determining how to pull the values from the classes and map them with table and associated fields.

Java classes whose objects or instances will be stored in database tables are called persistent classes or Entity classes in Hibernate.

Simple POJO Class

package com.javatutorialcorner.pojo;

public class Employee {

 private Long empId;
 private String firstName;
 private String lastName;
 private Integer age;
 private Double salary;

 public Long getEmpId() {
  return empId;

 public void setEmpId(Long empId) {
  this.empId = empId;

 public String getFirstName() {
  return firstName;

 public void setFirstName(String firstName) {
  this.firstName = firstName;

 public String getLastName() {
  return lastName;

 public void setLastName(String lastName) {
  this.lastName = lastName;

 public Integer getAge() {
  return age;

 public void setAge(Integer age) {
  this.age = age;

 public Double getSalary() {
  return salary;

 public void setSalary(Double salary) {
  this.salary = salary;

Annamalai Thangaraj

Annamalai is working as Technical Lead in Leading Telecom company with 5+ years experience in Identity and Access Management , Telecom and Networks, BigData, Java, Spring, Struts, Hibernate, AngularJS, and Enterprise Web Application Development.

Website: Java Tutorials Corner

Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments


Post a Comment

Item Reviewed: Hibernate Persistent Class Rating: 5 Reviewed By: Annamalai Thangaraj