This hibernation lesson provides in-depth concepts of the Hibernate Framework with simplified examples. It was launched in 2001 by Gavin King as an alternative to the EJB2-style entity bean.

Hibernate Framework

Hibernate is a Java framework that simplifies the development of a Java database interaction application. This is an open source tool, lightweight, ORM (Object Relational Mapping). Hibernate implements the Java Persistence API specifications for data consistency.

ORM tool

The ORM tool simplifies data creation, data manipulation, and data access. This is a programming technique that maps the object to the data stored in the database.

hibernation lesson, introduction to hibernation

The ORM tool internally uses the JDBC API to interact with the database.

What is a JPA?

The Java Persistence API (JPA) is a Java specification that provides specific functionality and standard for ORM tools. IN javax.persistence the package contains JPA classes and interfaces.

Advantages of the Hibernate Framework

Below are the benefits of the hibernation framework:

1) Open source and lightweight

The Hibernate framework is open source under the LGPL license and is lightweight.

2) Fast execution

Hibernation frame performance is fast because cache is used internally in hibernation frame. There are two types of cache in the hibernation framework, first-level cache and second-level cache. First level cache is enabled by default.

3) Database independent query

HQL (Hibernate Query Language) is an object-oriented version of SQL. It generates database-independent queries. So you don’t have to write database-specific queries. Before hibernation, if the database changes for the project, we need to change the SQL query, which leads to a maintenance problem.

4) Automatic table creation

The hibernation framework provides the ability to automatically create database tables. So there is no need to create tables in the database manually.

5) Simplifies complex joining

Extracting data from multiple tables is easy in hibernation.

6) Provides query statistics and database status

Hibernate maintains a cache of queries and provides statistics on the status of the query and the database.

Hibernation index

Hibernation lesson

Hibernate with Eclipse

An example of hibernation

Hibernation Log4j

Heritage mapping

Hibernation mapping

Tx control



Named request

Hibernate caching

Second level cache


Interview questions