Something About Hibernate

Hibernate is an Object Relational Mapping solution for Java, and it’s an open-source persistent framework.

It is a powerful, High Performance, Object Relational Persistence Query Service for any Java Application.

How Hibernate Functions:-

  • Hibernate maps Java Classes to Database Types and Java Data types to SQL data types, and thus it makes the life of a programmer easier.
  • Hibernate make use of XML configurations for mapping Java Classes to  database Objects.
  • Provides simple API for accessing Java Objects to and from the database.
  • Changes in the database can be reflected by changing the XML configuration file.
  • It Abstracts the SQL queries & helps us working with Java Objects.
  • It doesn’t require an application server to work.
  •  Can manage complex associations through Objects.
  • Ease in Data Retrieval
  • And It supports almost all RDBMS.
  • It uses existing Java API’s like JDBC ,JNDI, Java TransactionAPI. JDBC provides a rudimentary level of abstraction,and also it allows any database with a JDBC driver can be integrated with Hibernate.
  • JNDI and Java Transaction API (JTI) helps Hibernate to get integrated with J2EE application servers.


Hibernate sits between Traditional Java objects and database server to handle all the work in persisting objects based on appropriate Object-Relational mechanisms and patterns.

A High Level Hibernate Architecture


Objects which gave birth in an Hibernate Application

  • Configuration Object
  • Session Factory Object
  • Session Object
  • Transaction Object
  • Query Object
  • Criteria Object


  • Configuration Object

It’ the first ever object that get created in an Hibernate Application, and it’s created automatically during application initialization process. The two key components of Configuration Objects are :

  1. Database Connection => which is handled by and hibernate.cfg.xml.
  2. Class Mapping Setup => This helps in creating in connection with Java Classes and DB tables.
  •  Session Factory Object

The above mentioned Configuration Object is used to create Session Factory Object which inturn configures Hibernate for the application with the supplied configuration file => which instantiates a Session Object. Session Factory Object is created during application startup.We will need one SessionFactory Object per Database and vice versa.

  • Session Object

The basic purpose of this object is to get a physical connection with the database & this object will be instantiated each time when database interaction occurs. They are not thread safe( should be destroyed/created as needed).

  • Transaction Object

This is an optional object , and Hibernate applications may choose not to use this interface.

  •   Query Object

Query Objects use SQL or Hibernate Query Language string to retrieve data from the database and create objects.

  • Criteria Object

These objects are used to create and execute object oriented criteria queries to retrieve objects.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s