3. Understanding the Hibernate ORM
- Introduction:
- Hibernate is a popular Java-based ORM framework implementing the JPA specification.
- It abstracts database interactions, allowing developers to work directly with Java objects.
- Key Features:
- Automatic Table Mapping: Maps Java classes to database tables using annotations or XML configurations.
- Query Language: Hibernate Query Language (HQL) and support for native SQL queries.
- Caching: First-level and second-level caching for performance optimization.
- Lazy Loading: Loads associated objects only when accessed.
- Architecture Overview:
- Core components: Session, Transaction, Query, and Configuration.
- Configuration file (
hibernate.cfg.xml
) or Java-based configuration.
- Hibernate with JPA:
- JPA annotations like
@Entity
, @Id
, @GeneratedValue
are supported.
- Allows switching between different JPA-compliant providers.