Hibernate Architecture and API-

In this Hibernate Architecture tutorial we include all components. Hibernate Architecture is layered with many objects such persistent object, session factory, transaction factory, connection factory, session, transaction etc. Let see below diagram describing some basic hibernate functionality.

Hibernate Architecture

Hibernate Architecture design

It represents a configuration or properties file for Hibernate. The Configuration object is usually created once during application initialization. The Configuration object reads and establishes the properties Hibernate uses to get connected to a database and configure itself for work. A Configuration object is used to create a SessionFactory and then typically is discarded.

The SessionFactory is created from a Configuration object, and as its name implies it is a factory for Session objects.The SessionFactory is an expensive object to create. It, like the Configuration object, is usually created during application start up. However, unlike the Configuration object, It should be created once and kept for later use.

The SessionFactory object is used by all the threads of an application. It is a thread safe object. One SessionFactory object is created per database. Multiple SessionFactory objects (each requiring a separate configuration) are created when connecting to multiple databases. The SessionFactory can also provide caching of persistent objects. -Dinesh

Hibernate Architecture Diagram

Session objects provide the main interface to accomplish work with the database. Persistent objects are saved and retrieved through a Session object. A Session object is lightweight and inexpensive to create. A Session object does the work of getting a physical connection to the database. Session objects maintain a cache for a single application thread (request).

Session objects are not thread safe. Therefore, session objects should not be kept open for a long time.Applications create and destroy these as needed. Typically, they are created to complete a single unit of work, but may span many units. -Dinesh

it represents unit of works.

Query and Criteria
These objects are used to retrieve (and recreate) persistent objects.

Next Chapter 3 –Setting Up Hibernate To Eclipse

 <<Previous Chapter 1<<    >>Next Chapter 3>>