Showing posts with label Architecture of hibernate. Show all posts
Showing posts with label Architecture of hibernate. Show all posts

Wednesday, 25 June 2014

Hibernate

Hibernate -

Hibernate is an open-source Java Persistence framework that lets applications connect to and work with relational databases using Object Relational Mapping . It implements the Java Persistence API - JPA which is the standard specification for object - relational mapping.Persistence is a process of storing the data to some permanent medium and retrieving it back at any point of time even after the application that had created the data ended.

 Architecture - 


Fig (a) Architecture of hibernate 

            The above diagram shows architecture of Hibernate. It creates a layer between Database and the Application. It loads the configuration details like Database connection string, entity classes, mappings etc.

Elements of the hibernate - 

SessionFactory

              The SessionFactory is a factory of session and client of ConnectionProvider. It holds second level cache (optional) of data. The org.hibernate.SessionFactory interface provides factory method to get the object of Session. 

Session

         The session object provides an interface between the application and data stored in the database. It is a short-lived object and wraps the JDBC connection. It is factory of Transaction, Query and Criteria. It holds a first-level cache (mandatory) of data. The org.hibernate.Session interface provides methods to insert, update and delete the object. It also provides factory methods for Transaction, Query and Criteria.
 

Transaction

            The transaction object specifies the atomic unit of work. It is optional. The org.hibernate.Transaction interface provides methods for transaction management.

ConnectionProvider

               It is a factory of JDBC connections. It abstracts the application from DriverManager or DataSource. It is optional.

 

TransactionFactory

               It is a factory of Transaction. It is optional.