Hibernate is an open source, lightweight Object Relational Mapping (ORM) tool. It simplifies the development of java application to interact with the database. It is a programming technique for mapping the objects to the data in the database.

Hibernate Architecture:

Hibernate Architecture has four layers and the layers are java application layer, hibernate framework layer, backhand API layer, and database layer. The elements of Hibernate Architecture are Session, SessionFactory, Transaction, ConnectionProvider, and TransactionFactory.

Features of Hibernate:


ORM (Object Relational Mapping) is a programming technique which converts data between relational databases and object-oriented programming languages. Hibernate supports ORM.

SessionFactory Interface:

It hibernates an application using config files like hibernate.properties and hibernate.cfg.xml. If multiple databases are used, then multiple SessionFactory objects should be created.

Hibernate Session Interface:

The connection to the database is made when the session object is instantiated.

Transaction Interface:

The transaction will track the errors between the start and end of the database query. Most of the RDBMS supports transaction functionality and in Hibernate, transactions are handled by an underlying transaction manager.

Query Interface:

This interface helps the developer to query the database for the objects. Query objects use SQL or HQL (Hibernate Query Language) to retrieve data from the database.

Advantages of Hibernate:

  • HQL (Hibernate Query Language) is database independent.
  • It converts checked exception into unchecked exception so no need to use try, catch, throw and throws.
  • Apart from XML, it supports annotations.
  • HQL helps the developers to write database independent commands.
  • Fetching of data from multiple tables is easy in this framework.
  • Supports Query cache and provides statistics about query and database status.

Disadvantages of Hibernate:

  • The processing time will be longer even for smaller applications and it takes the same time as processing a larger application.
  • The main disadvantage is the boilerplate code issue.

Categorized in:

Tagged in: