The core interfaces are used in just about every Hibernate application. Using these interfaces, you can store and retrieve persistent objects and control transactions.
- Session interface
- SessionFactory interface
- Transaction interface
- Query and Criteria interfaces
Hibernate is a popular object-relational mapping (ORM) framework for Java, and it provides several core interfaces that play key roles in its functionality. Here are some of the core interfaces of the Hibernate framework:
- Session: The
Session
interface is a runtime interface between a Java application and Hibernate. It provides methods for CRUD (Create, Read, Update, Delete) operations, as well as other operations like querying the database. - SessionFactory: The
SessionFactory
interface is used to create sessions. It is a heavyweight object and should be instantiated once per application. TheSessionFactory
is responsible for managing the HibernateSession
objects. - Configuration: The
Configuration
interface is used to configure and bootstrap Hibernate. It represents a configuration settings and properties that Hibernate will use to connect to the database. - Transaction: The
Transaction
interface represents a single unit of work and abstracts the code from the underlying transaction management system (JTA or JDBC). It allows developers to control the boundaries of transactions. - Query and Criteria: Hibernate provides two interfaces for querying the database –
Query
andCriteria
. TheQuery
interface allows you to execute HQL (Hibernate Query Language) queries, while theCriteria
interface allows you to create and execute queries using a programmatic and type-safe approach.
These are some of the core interfaces in Hibernate, and understanding their roles and usage is crucial for working effectively with the framework.