Hibernate - Architecture Overview

In Hibernate Architecture is layered with many object like as transaction factory, session ,session factory ,persistence Object transaction. let's see bellow diagram describe some basic hibernate functionality. 

1. Configuration (org.hibenrate.cfg.Configuration): In this section represent a configuration or properties file for Hibernate.The configuration object created once when application initialization.The configuration object read and make the connection to relational database.
The Configuration object provides two keys factor:

  • Database Connection:This is handled through one or more configuration files support Hibernate.The name of these file are hibernate.properties and hibernate.cfg.xml.
  • Class Mapping Setup: this component create the connection between java class and relation database tables.


2. Session-Factory (org.hibernate.SessionFactory): The Session-Factory is thread-safe as it is created one per database and can be concurrently accessed by multiple threads and created at time of application startup. Session-Factory created using Configuration object.
session-factory can hold an optional (Second level)cache of data that is reusable between transaction at process ,cluster level.

3. Session (org.hibernate.Session) :The Session is used to create object that are used to communicate between java application and persistence store database.This is factory for transaction and it is not thread-safe.Session holds a mandatory first-level cache of persistence object.

4. Transaction (org.hibernate.Transaction) :
Transaction is not thread safe and it is associated with a session and it usually instantiated by call to Session.beginTransaction().

5. Query (org.hibernate.Query):Query Object use SQL or Hibernate Query Language(HQL) string to retrive data from the database and create object.Query instance is obtained by call Session.createQuery().

6. Criteria (org.hibernate.Criteria): Criteria Object are used to create and execute object oriented criteria query to retrieve object.

No comments: