Architecture of Hibernate


High level architecture

Hibernate architecture is layered to keep us isolated from having to know the underlying API’s. There are four layers in hibernate architecture:

·         Java Application layer

·         Hibernate Framework layer

·         Backhand API layer and

·         Database layer.


Hibernate make use of the database and configuration data to provide persistence services (and persistent objects to the application.

·         It includes several objects:

·         Persistent Object

·         Session Factory

·         Transaction factory

·         Connection Factory

·         Session

·         Transaction etc.

Components of Hibernate Architecture:

Apart from the objects, hibernate framework also use existing Java API such as:

·         JDBC (Java Database Connectivity)

·         JTA (Java Transaction API)

·         JNDI (Java Naming Directory Interface)


For working with Hibernate application we must know the elements involved in Hibernate architecture:

Session factory: This object is the factory of sessions and client of ConnectionProvider. It holds second level cache (optional) of data. The org.hibernate. SessionFactory interface provide factory method to get the object of Session.

Session: This object provides an interface between the application and data stored in the database. It is a short-lived object and wraps the JDBC connection. It is factory of Transaction, Query and Criteria. It holds a first-level cache (mandatory) of data. The org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for Transaction, Query and Criteria.

Transaction: This object specifies the atomic unit of work. It is optional. The org.hibernate.Transaction interface provides methods for transaction management.

Connection Provide: It is a factory of JDBC connection. It abstracts the application from DriverManager or Datasource. It is optional

TransactionFactory: It is a factory of Transaction. (It is optional)




Leave Comment