Hibernate
The most widely used ORM and JPA implementation for Java.
Overview
Hibernate ORM maps Java classes to database tables and takes care of generating SQL, managing connections and caching. It implements the JPA standard and also offers its own extra features such as HQL, filters and advanced caching.
It is the engine behind Spring Data JPA in most projects, so knowing Hibernate well helps you write faster, cleaner data code and diagnose performance problems.
Where it is used
- Enterprise data access layers
- Spring Boot back-ends
- Migrating from JDBC to ORM
- Performance tuning of database-heavy applications
Using a Session
try (Session session = sessionFactory.openSession()) {
Transaction tx = session.beginTransaction();
Student s = new Student();
s.setName("Anu");
session.persist(s);
tx.commit();
}
What you will cover
The key topics and features of Hibernate
SessionFactory & Session
The core objects used to open sessions and work with entities.
HQL
Hibernate Query Language for object-based queries.
Lazy & Eager Loading
Control when related data is fetched and avoid the N+1 problem.
Caching
First-level and second-level caches to reduce database load.
Schema Generation
Create and update tables from your entity classes during development.
Batch Processing
Insert and update large amounts of data efficiently.