Hibernate Persistence

This tutorial describes the concept of Hibernate persistence

Hibernate Persistence

Hibernate Persistence

This tutorial describes the concept of Hibernate persistence.

Hibernate persistence:

Hibernate persistence manages your database and the mapping between the database and the object.
Many tools facilitating the concept of persisting java objects to a relational database.
Hibernate is one of them. It permits developer to persistence engines in converting database column to java object and back.


Persistence class are simple POJO classes in an application. It works as implementation of the business application
for example Employee , department etc. It is not necessary that all instances of persistence class are defined persistence.

Example:

package net.roseindia.table;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

@Entity
@Table(name = "employee")
public class Employee {
@Id
@GeneratedValue
@Column(name = "emp_id")
private int id;

@Column(name = "name")
private String name;

@Column(name = "salary")
private int salary;

@Column(name = "date_of_join")
private Date dateOfJoin;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getSalary() {
return salary;
}

public void setSalary(int salary) {
this.salary = salary;
}

public Date getDateOfJoin() {
return dateOfJoin;
}

public void setDateOfJoin(Date dateOfJoin) {
this.dateOfJoin = dateOfJoin;
}

}

Description: The javax.persistence package contains the classes and interfaces that is used to define the relationship between persistence provider and the managed classes the client of java persistence API.