---
title: "Architecture of Hibernate"  
description: "Hibernate architecture is layered to keep us isolated from having to know the underlying API’s. There are four layers in hibernate architecture."  
author: "Anonymous User"  
published: 2015-10-30  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/11894/architecture-of-hibernate  
category: "java"  
tags: ["java", "orm", "hibernate"]  
reading_time: 2 minutes  

---

# Architecture of Hibernate

##### High level architecture

Hibernate [architecture](https://yourviews.mindstick.com/story/1913/7-surprisingly-weird-architecture-facts-you-probably-didn-t-know) is layered to keep us isolated from having to know the underlying API’s.

##### There are four layers in hibernate architecture:

· Java [Application layer](https://answers.mindstick.com/qa/97104/which-protocols-use-the-application-layer)

· Hibernate Framework layer

· Backhand API layer and

· Database layer.

\
![Architecture of Hibernate](https://www.mindstick.com/mindstickarticle/2c6498dc-41bc-4090-9905-67391235ee27/images/6eba0ad9-34df-4ed9-810f-e7e6c64113c8.png)

\

##### 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)

![Architecture of Hibernate](https://www.mindstick.com/mindstickarticle/2c6498dc-41bc-4090-9905-67391235ee27/images/ff620ab2-3b91-433e-8714-431c59632359.png)

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](https://www.mindstick.com/forum/561/how-come-refs-does-not-have-deduplication-second-level-caching-between-dram-storage-and-writable-snapshots) cache (optional) of data. The org.hibernate. SessionFactory interface provide [factory method](https://www.mindstick.com/forum/34032/factory-method-design-pattern-using-c-sharp) to get the object of Session.

Session: This object provides an interface between the application and [data stored](https://www.mindstick.com/interview/23089/how-to-create-grid-view-in-c-sharp-data-stored-in-sql-server) in the database. It is a short-lived object and wraps the JDBC [connection](https://yourviews.mindstick.com/view/83497/a-40-year-old-man-has-been-arrested-in-connection-with-the-abe-shooting). It is factory of [Transaction](https://www.mindstick.com/blog/175/transactions-in-database), Query and Criteria. It holds a first-level cache (mandatory) of data. The org.hibernate.Session interface provides methods to insert, [update and delete](https://www.mindstick.com/forum/353/insert-update-and-delete-records-in-php) the object. It also provides factory methods for Transaction, Query and Criteria.

Transaction: This object specifies the atomic [unit of work](https://www.mindstick.com/articles/13071/generic-repository-pattern-with-unit-of-work-uow). 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)

---

Original Source: https://www.mindstick.com/articles/11894/architecture-of-hibernate

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
