Hibernate - SPLessons

Hibernate Architecture

Chapter 4

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Hibernate Architecture

Hibernate Architecture

shape Description

The chapter explains about Hibernate Architecture to deal with hibernate project developer need to have database support like MySQL to create the table, the primary advantage of Hibernate code is the creation of a table. Hibernate is also an open source and lightweight framework and It can be also known as ORM tool. Hibernate underpins inheritance also and underpins relationships like one to one, one to many and underpins collections also. ORM tool used to access the data. Hibernate is persistence. In Hibernate, data will be transferred from Java Application to the Database in four Layers.

shape Conceptual

The Conceptual figure below explains the Hibernate Architecture.
  • In Hibernate, all the data will be transferred from the Java Application to Database using the Hibernate Persistence object.
  • Hibernate contains Mapping properties and Configuration Properties.
  • Hibernate internally uses existing Java API like JDBC API, JTA(Java Transaction API), JNDI (Java Naming and Directory Interface).
  • JDBC provides operations on relational Databases(Abstraction), Hibernate supports any type of database and JDBC Driver. If needed to create any Connection pool Object at that time JNDI is used.
  • Whenever the data needs to transfer from Java Application to DataBase then JTA is used. Hibernate is integrated with J2EE application servers.

Hibernate Architecture Framework includes many objects like Persistence Object, Configuration, SessionFactory, Session, Transaction, Query, and Criteria.

shape Conceptual

The below conceptual Figure explains Hibernate Architecture Framework.

Configuration Object

To create any Hibernate application or when any Hibernate Application is initialized, first create the Configuration Object. Hibernate can provide connection between Java Classes and Database tables. This is taken care of through different Configuration records bolstered by Hibernate. These Files are hibernated.cfg.XML, hibernate properties.

Session Factory

Configuration Object is utilized to create a Session Factory Object. It can read the all Configure Properties and provides the operations. It initializes the Session Object.

Session Factory is a thread-safe object and it is used in all thread-based applications.
Session Factory Object is the Heavy-Weight object. This object is created only once and later it will be using multiple times.


The session is utilized to get a physical association with the database. Session is a Light-Weight Object. The session will be made for each database operation and Session is introduced by utilizing SessionFactory Object. By Using the Session Object, persistence items are spared and recovered. Session Object is not a string safe item. Along these lines, Session Object can close or decimate unfailingly.


A Transaction speaks to a Unit of work with a Database table operations. Transactions of Hibernate is handled by Transaction Manager or JNDI and JTA. Transaction object is optional. The transaction can be used in the Hibernate to perform some operations. Once a Transaction object is created, one have to commit that transaction.


To perform any operations in SQL or Hibernate object, create Query Object.


Criteria Object is used only to perform SELECT Query.


shape Key Points

  • Session factory is thread safe object.
  • ORM has the ability to convert the information between relational data bases and object oriented languages.