Hibernate Architecture

In this tutorial we are going to describe hibernate architecture with example.


Hibernate 5.3 features Hibernate 5 JPA Configuration Hibernate 5 persistence.xml example Hibernate 5 JPA Tutorial Hibernate and JPA Example How properties of a class are mapped to the columns of a database table in Hibernate? Hibernate 5 Annotations Maven dependency Hibernate 5 annotationconfiguration Doctype Hibernate-configuration 5 Hibernate 5 Dialect Hibernate 5 configuration dtd Hibernate 5 Hello World Getting started with Hibernate 5 Hibernate 5.2.10 jar Download Hibernate 5.2.10 Maven Dependency Hibernate 5 Maven Dependency Hibernate 5 native query example Hibernate 5 query deprecated When should you use Hibernate? What's new in Hibernate 5? How much time it takes to learn Hibernate? Hibernate envers custom revinfo table Hibernate 5 Envers Hibernate Envers get all revisions Hibernate Examples Hibernate 5 build SessionFactory Example Hibernate 5 SessionFactory Example Hibernate 5 Annotation Example How to download Hibernate 5.x? Hibernate 5 Features Hibernate 5 Tutorials Learning Hibernate ORM - Free Training/Tutorial videos of Hibernate ORM with Java How to write hello world example program in Hibernate? How to create one to one relationship in Hibernate 4 with Annotation? How to calculate minimum in Hibernate using the min() Function Hibernate ORM 4.2.21.Final Released - Create CURD application in latest Hibernate Hibernate ORM 4.2.21 Tutorial - Learn Hibernate ORM Framework Hibernate Error: Failed to create sessionFactory object.java.lang.NoClassDefFoundError How to create Hibernate Project in Eclipse? Examples of Hibernate Criteria Query

Hibernate Architecture

In this tutorial we are going to describe hibernate architecture with example.

Hibernate Architecture :

It is layered architecture. So you are away from the underlying APIs. Hibernate is written in java and you can configure it in two ways-
first by using configuration file named hibernate.cfg.xml and another by using *.hbm.

Diagram : Here is diagram of Hibernate architecture.

The above diagram shows how hibernate uses database and configuration data to provide persistent object to your application.

JDBC is not the only technology used between Hibernate and database server  but there are  more java APIs like JTA(Java Transaction API),JNDI(Java Naming and Directory Interface).
Now we are going to give you brief description of architecture -

Hibernate Configuration :

Configuration class perform two operations. You can say Configuration class has two component-database connection and class mapping setup.
The first component is handled through one or more configuration files supported by Hibernate. These files are hibernate properties and hibernate.cfg.xml.
Second component that is class mapping, it creates the connection between java classes and database tables.

Hibernate SessionFactory : 

For SessionFactory import org.hibernate.SessionFactory. SessionFactory is factory for Sessions and is created in your configuration file.
When your application start ,it is created. For each database ,there is one SessionFactory.
If you are using more than one database you need to create multiple SessionFactory object. It is thread safe object.
It also maintains second level cache of data that is reusable between transactions at a process or cluster level but it is optional.

Hibernate Session :

For Session Object import org.hibernate.Session. It is used for database connection. It is very lightweight and
single-threaded. It lives for short time, represents conversation between the application and the persistent store.
Session object is used for saving and retrieving persistent objects. Session object is not thread safe so do not open it for long time.
You can create and destroy as your need.

Hibernate Transaction :

For Transaction import class org.hibernate.Transaction.It is optional.
Transaction is single threaded and short-lived object ,used for a unit of work with the database.
Most of the RDBMS supports transaction functionality. Transaction manager handle your transactions.

Hibernate Query :

Hibernate provide simple SQL  ,native query and HQL for  performing different database operations. At last execute query to complete your operation.

Hibernate Criteria :

 Hibernate provide a high object oriented concept of criteria. Criteria objects are used to perform database operations
under object oriented concepts.


Share on Google+Share on Google+

Hibernate Architecture

Posted on: July 20, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles



Discuss: Hibernate Architecture  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image