Hibernate architecture

We will see Hibernate architecture in 2 views

1) High level view of Hibernate Architecture

2) Detailed view of Hibernate Architecture

Hibernate architecture shows configuration details and various objects involved in each layer
Hibernate uses Java API like JDBC API,Java Transaction API(JTA) and Java Naming and directory Interface(JNDI)

The below figure illustrates High Level View of Hibernate Architecture


The below figure illustrates Detailed View of Hibernate Architecture


Let’s discuss various elements involved in Hibernate architecture


It represents a configuration required to use the hibernate , which could be properties file or XML file.
The Configuration object is usually created once during application initialization.
The Configuration object uses the configuration details from the configuration file to get connected to a database.
A Configuration object is used to create a SessionFactory.

Object Relational Mapping

The mapping between Java POJO class and the database tables is provided using either XML or annotation.


It is the factory for the session objects.
It is thread safe and immutable object representing the mappings for a single database.
It can hold the second level cache in hibernate


It’s a single-threaded, short-lived object which acts as a bridge between Java application and Hibernate.
It wraps a JDBC connection and is a factory for Transaction.
Session holds a mandatory first-level cache of persistent objects

Transient objects

Instances of persistent classes which are not currently associated with a Session

Persistent objects

They are associated with Session and Once the Session is closed, they will be detached and free to use in any application layer


Query objects use Native SQL or Hibernate Query Language (HQL) to retrieve data from the database.
A Query instance is used to bind query parameters such as number of results returned by the query.
We can obtain the query object from the session using session.createQuery()


The org.hibernate.Criteria is used to retrieve the entities based on some criteria like getting all employees by specific age or specific date of joining etc.
We can get the Criteria from the Session.


A factory for Transaction instances,It is not exposed to the application and it’s optional.


single-threaded, short-lived object used by the application to specify atomic units of work
We can obtain the transaction from the Session object.


It’s a pool of JDBC connections

About the Author

Founder of javainsimpleway.com
I love Java and open source technologies and very much passionate about software development.
I like to share my knowledge with others especially on technology 🙂
I have given all the examples as simple as possible to understand for the beginners.
All the code posted on my blog is developed,compiled and tested in my development environment.
If you find any mistakes or bugs, Please drop an email to kb.knowledge.sharing@gmail.com

Connect with me on Facebook for more updates

Share this article on