Respuesta:
Hibernate is a popular Object-Relational Mapping (ORM) framework for Java that simplifies database interactions. The core interfaces of Hibernate provide the essential functionalities for managing the persistence of Java objects. Here are the key interfaces:
-
Session:
- The primary interface for interacting with the Hibernate framework. It represents a single unit of work with the database and is used to create, read, update, and delete operations on persistent objects. It also provides methods for managing transactions.
-
SessionFactory:
- A thread-safe factory for creating
Session
instances. It is typically created once during application startup and is used to configure Hibernate settings and manage the connection to the database.
-
Transaction:
- Represents a database transaction. It provides methods to begin, commit, and roll back transactions. It is used in conjunction with the
Session
interface to ensure that operations are performed atomically.
-
Query:
- An interface for creating and executing HQL (Hibernate Query Language) or SQL queries. It allows for parameter binding and provides methods to retrieve results.
-
Criteria:
- An interface used to create queries using a programmatic approach. It allows for building queries dynamically and is useful for creating complex queries without writing HQL or SQL.
-
CriteriaBuilder:
- Part of the JPA Criteria API, it provides methods to construct
CriteriaQuery
objects, allowing for type-safe queries.
-
CriteriaQuery:
- Represents a query object that is constructed using the
CriteriaBuilder
. It is used to define the query structure and criteria.
-
QueryFactory:
- An interface that provides methods to create
Query
instances. It is often used in conjunction with the Session
interface.
-
StatelessSession:
- A specialized session that does not maintain a first-level cache. It is useful for batch processing and when you do not need the overhead of a session cache.
-
Interceptor:
- An interface that allows for intercepting and customizing the behavior of Hibernate operations. It can be used for logging, auditing, or modifying the state of entities before they are persisted.
These interfaces form the backbone of Hibernate's functionality, allowing developers to interact with the database in an object-oriented manner while abstracting away the complexities of JDBC and SQL.