Learn with best explanation

Coding tutorials and solutions

Hibernate tutorial

This series of tutorial will provide in-depth knowledge hibernate with simple and easy example.


Hibernate framework is a tool based on Object Relational Mapping (ORM) methodology or concept for Java language. It helps developer to map simple Java objects to database tables. It's open source and light weight. It implements JPA (Java persistence API) which is specification for data persistence. By using ORM framework it becomes very easy to store data into database and retrieve it back.

ORM Object Relational Mapping javakar.com

Difference between hibernate and JPA

Hibernate is commonly used ORM framework for java it provides facility of mapping java objects to relational database structure.

JPA is specification (like interface) and hibernate is implementation of it (like class implements interface). There are several implementations of JPA and alternatives of Hibernate i.e Eclipse Link, MyBaits, Top Link. JPA works as bridge between Hibernate and Java Application. Whenever any ORM tool doesn't suit development requirements it can easily be changed without modifying code and this is possible just because of JPA.

Advantages of hibernate framework

Following are the advantages of hibernate.

  1. It's light weight and open source and easy to use.
  2. It has fast performance because cache is internally used in hibernate framework. It has two caches first level cache and seond level cache and by default first level cache is enabled.
  3. It provides the facility to create the tables of the database automatically. So there is no need to create tables in the database manually.
  4. it simplifies joins and relations fetching data from multiple tables is easy in hibernate framework.
  5. It supports Query cache and provide statistics about query and database status.
  6. HQL (Hibernate Query Language) is the object-oriented version of SQL. It generates the database independent queries. So you don't need to write database specific queries. Before Hibernate, if database is changed for the project, we need to change the SQL query as well that leads to the maintenance problem.