Core Interfaces in Hibernate Framework

This post describes the core interfaces in Hibernate Framework.

Hibernate is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database. Object-relational mapping (ORM) is a programming technique for converting data between incompatible type systems in object-oriented programming languages.

Core Interfaces in Hibernate Framework

1.SessionFactory interface
2.Session interface
3.Configuration interface
4.Transaction interface
5.Query and Criteria interfaces

1. SessionFactory interface

SessionFactory interface object is a thread-safe (and immutable) representation of the mapping of the application domain model to a database. Acts as a factory for org.hibernate.Session instances. The EntityManagerFactory is the JPA equivalent of a SessionFactory and basically, those two converge into the same SessionFactory implementation.
SessionFactory is very expensive to create, so, for any given database, the application should have only one associated SessionFactory. The SessionFactory maintains services that Hibernate uses across all Session(s) such as second-level caches, connection pools, transaction system integrations, etc.
2. Session interface 

It is a single-threaded, short-lived object conceptually modeling a "Unit of Work". In JPA nomenclature, the Session is represented by an EntityManager.
Behind the scenes, the Hibernate Session wraps a JDBC java.sql.Connection and acts as a factory for org.hibernate.Transaction instances. It maintains a generally "repeatable read" persistence context (first level cache) of the application domain model.
3. Configuration interface 

This interface is used to configure and bootstrap hibernate. The instance of this interface is used by the application in order to specify the location of hibernate specific mapping documents.

4. Transaction interface 

Transaction is a single-threaded, short-lived object used by the application to specify atomic units of work. It abstracts the application from the underlying JDBC or JTA transaction. An org.hibernate.Session might span multiple org.hibernate.Transaction in some cases.

5. Query and Criteria interfaces

This interface allows the user to perform queries and also control the flow of the query execution.