Hibernate Tutorial for Beginners

What is Hibernate?

Hibernate is an Object-Relational Mapping (ORM) tool which reduces the difficulty in the application development. Hibernate provides a framework that interacts with the data stored in the databases. It also uses the specifications of the Java Persistence API (JPA) and licensed by GNU Lesser General Public License (LGPL). It supports almost all relational databases.

Gavin King is known as the father of hibernate. Hibernate can be used both in Java SE (Standard Edition) and Java EE (Enterprise Edition).

Hibernate is an essential component of JBoss EAP (Enterprise Application Platform). JBoss tools provide a smooth implementation and testing of code in application development.

What is ORM tool?

An Object-Relational Mapping tool helps to clarify the creation, manipulation, and access to the data. With this technique, the object is mapped to the data stored in the database. ORM is used to solve some mismatch problems like

  • Granularity– It is defined as an object which can further be divided into new data fields. For example, a person as an entity. We can divide ‘person’ into new more attributes like name, address, contact, etc.  
  •  Inheritance– Inheritance enables a sub/child class to inherit the properties and attributes of its super/ parent class.
  •  Identity– A Relational databases provide a small concept of identity. It is referred to as a column that automatically generates numeric values.
  • Association– It defines a relation between two objects based on a common attribute.
  • Navigation– It is a database in which records and objects are found through the reference of other objects. The method of object access is different in both Java and RDBMS.
hibernate introduction

Java Persistence API (JPA)

JPA defines a set of functionalities, standards, and concepts to the ORM tool. It is available in the javax.persistence package. To decrease the line of codes for relational object management, a coder must follow the “JPA Framework,” which easily allows interaction with the database.

 JPA is an open-source framework and was first released on May 2006. There are many enterprise vendors like Oracle, Eclipse, etc. which provide new JPA products.

Hibernate framework Tutorial Topics

Hibernate Tutorials 

Introduction to Hibernate

Hibernate History

Hibernate Features

Hibernate Architecture

Hibernate Session Factory

Hibernate Session

Hibernate Examples

Hibernate First Example

Hibernate Annotations Example

Web Application Example

Hibernate GeneratedValue Strategies                                       

Hibernate Dialects

Hibernate Inheritance Mapping

Single Table Strategy

Table per Class Strategy

Joined Table Strategy

Hibernate Mapping

Hibernate Mapping

Hibernate One-to-One Mapping

Hibernate One-to-Many Mapping

Hibernate Many-to-One Mapping

Hibernate Many-to-Many Mapping

Hibernate Named Query

Hibernate Named Query using XML file

Hibernate Named Query using annotation

Hibernate Caching

Hibernate Caching

First level Cache

Second Level Cache

Hibernate Query Language (HQL)

Hibernate Criteria Query Language (HCQL)


N+1 SELECT problem in hibernate

Dirty checking in hibernate

Lazy loading

Hibernate configuration file

Cascade in Hibernate

Hibernate life cycle

Inverse in Hibernate

Merge in Hibernate

Composite key in Hibernate

Load() vs. get() 

Merge() vs. update()

Save() vs. persist()

JDBC vs. Hibernate

JPA vs. Hibernate

Spring mvc + hibernate example

Registration form using spring and hibernate

Spring mvc + hibernate login example