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.
