Hibernate architecture

Hibernate architecture consist of hibernate core components and use existing Java APIs. It uses JDBC API for common functionality to communicate with relational database and JNDI and JTA to integrate hibernate to the java application servers.

Diagram:

Core Components of Hibernate architecture:

Configuration object:

The configuration object consist the configuration file used by the hibernate. It mainly consist the information about database connection (hibernate.cfg.xml) and class mapping (.hbm.xml). Configuration object is used to create the object of SessionFactory.

SessionFactory object:

The SessionFactory object is created from the Configuration object. It is thread-safe object and used by all threads of the application. It acts as a factory for session objects and client for ConnectionProvider. It maintains the second level cache of the data.

Session object:

The session object is created from the SessionFactory object. It acts as a factory for Transaction, Query and Criteria. Session objects are not thread-safe. It maintains the first level cache.

Transaction object:

The Transaction object is created from Session object. A transaction object represents an atomic unit of work.

Query object:

The Query object is created from Session object. It uses SQL and HQL to perform database operations.

Criteria object:

The Criteria object is created from the Session object. It is used to define and execute the object oriented criteria queries.

Next Topic: Hibernate configuration file with example.
Previous Topic: Hibernate framework.