In this tutorial you will learn about the Hibernate architecture.
Here we will understand about the architecture of Hibernate using a diagram. A diagram given below is a very high level view of Hibernate architecture.
The above image demonstrates that a Hibernate architecture maintains a layer into which each layer isolates you from having to know the underlying API's, and also specified that there is a layer between application and the database. Hibernate produces an object called persistence object that synchronizes the data between the database and the application.
Above diagram explains the Hibernate architecture broadly. Use of Hibernate to persist data at first we will need an Entity class (mapped with database table) that will be instantiated by created by Hibernate, an instance of SessionFactory will be made. Factory design pattern is implemented by SessionFactory and it loads hibernate.cfg.xml file. Session object that is made from SessionFactory object is acted as a single connection with database, this connection is made by an instance of Session interface. Transaction API in Hibernate abstracts the JDBC or JTA transaction to the application.
Configuration : Configuration instance is used to provide the application to assign properties and mapped the documents when the SessionFactory is creating.
SessionFactory : SessionFactory is responsible for creating a Session instances to communicate with the database. SessionFactory object is a thread safe (immutable) and it is created once as per database.
TransactionFactory : TransactionFactory is responsible for generating a Transaction instances.
ConnectionProvider : Using ConnectionProvider Hibernate obtains a JDBC connections.
Session : Session interface is a major runtime interface between an Application and Hibernate. Main functionality of Session is to create, read, and delete operations of the mapped entity classe's instance.
Query : This interface represents a Hibernate query as Object-Oriented. An instance of Query is found by Session.createQuery().
Criteria : Criteria is used to retrieve entities by criterion objects.
Components of Hibernate Architecture
There are three main components of Hibernate Architecture :
Connection Management : This service allows database connection management in an effective manner.
Transaction Management : This service allows for executing a several database statements at a time.
Object Relational Mapping : ORM technique is used for mapping the data representation from an object-oriented model to a relational database.
When Hibernate is used with the above all three components then it is called FullCream architecture while it is called Lite architecture if there is only ORM component is used.
Posted on: February 16, 2012 If you enjoyed this post then why not add us on Google+? Add us to your Circles