Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Udacity

Data Persistence with Hibernate and JPA

via Udacity

Overview

Udacity Diwali Sale: 10% Off All Programs
Use code DIWALI2026 at checkout for 10% off a monthly plan, bundle, or single Nanodegree. For payments in INR. Ends Nov 11.
Get 10% Off
This course, "Data Persistence with Hibernate and JPA," provides a comprehensive exploration of database management in Java applications. Students will learn JDBC fundamentals, connection pooling, and the JPA architecture, focusing on entity lifecycles and mappings. The curriculum covers various relational relationships, advanced mappings, and caching strategies with Hibernate. Performance optimization techniques addressing the N+1 problem are also included. By leveraging JPQL, Criteria API, and native queries, participants will master complex queries and pagination techniques. Additionally, the course delves into transaction management, including locking strategies. The final project involves building a transactional banking persistence platform, integrating all learned concepts.

Syllabus

  • Course Introduction — Meet the course, see how you'll progress from raw JDBC to JPA, Hibernate, and Spring Data JPA on PostgreSQL, and check the tools and Java background you'll need.
  • Understand JDBC and Connection Pooling — See how Java talks to a database through JDBC, why opening connections is costly, and how a pooled DataSource, prepared statements, and batching keep apps fast and safe.
  • Apply JDBC with HikariCP Connection Pooling — Watch a concert tracker use raw JDBC with HikariCP, then build a customer repository and benchmark how pool size affects throughput under concurrent load.
  • Understand JPA Architecture and Entity Lifecycle — Learn how JPA tracks objects in the persistence context, the four entity states and the EntityManager calls that move between them, and how id strategies shape SQL timing.
  • Apply JPA Entity Mapping and Lifecycle Operations — Follow a pilot roster through every JPA lifecycle state, then map Customer and Order entities and trace when IDENTITY and SEQUENCE ids fire each INSERT.
  • Understand One-to-One and Many-to-One Relationships — Understand @OneToOne and @ManyToOne mappings: owning versus inverse sides, why LAZY fetching should be your default, and how cascades and orphan removal behave.
  • Apply One-to-One and Many-to-One Mappings — See single-valued mappings in a vet clinic, then map a shared-key User and UserProfile and a lazy Order-to-Customer link, and fix the N+1 queries lazy loading can cause.
  • Understand One-to-Many and Many-to-Many Relationships — Understand @OneToMany and @ManyToMany: which side owns the foreign key, keeping bidirectional collections in sync, and when a join table should become its own entity.
  • Apply One-to-Many and Many-to-Many Mappings — Map albums, tracks, and artists in a demo, then build a BlogPost-Comment one-to-many with orphan removal and a Student-Course many-to-many through an Enrollment entity.
  • Understand Advanced Entity Mappings — Map rich Java models onto flat tables with embeddables, element collections, inheritance strategies, composite keys, enum mapping, and attribute converters.
  • Apply Advanced Entity Mappings — Explore embeddables, element collections, and a Money converter in a restaurant menu, then map Address, a JOINED Payment hierarchy, and Money for an order system.
  • Understand Hibernate Caching Strategies — Compare Hibernate's first-level and second-level caches, cache regions, concurrency strategies, and the query cache, and learn when caching risks serving stale data.
  • Apply Hibernate Second-Level Caching — Cache a country dataset and read Hibernate's statistics, then enable the second-level cache on a product catalog and benchmark the drop in database queries.
  • Understand the N+1 Problem and Performance Patterns — Learn how the N+1 problem arises and how to spot it in logs and statistics, then compare JOIN FETCH, entity graphs, @BatchSize, and DTO projections as fixes.
  • Apply N+1 Detection and Resolution — Reproduce N+1 in a library demo, then fix a blog's lazy comments three ways, with JOIN FETCH, @EntityGraph, and @BatchSize, and compare the query counts.
  • Understand JPQL and the Criteria API — Compare JPQL and the Criteria API: parameters, joins, and DTO projections in JPQL, and type-safe, dynamic queries built with CriteriaBuilder and predicates.
  • Apply JPQL and Criteria for Complex Queries — Query a product catalog with both JPQL and Criteria, then write a top-customers JPQL report and a dynamic Criteria order search driven by optional filters.
  • Understand Native Queries and Pagination — Learn when to drop to native SQL, how to map native results into typed DTOs, and why keyset pagination outperforms offset paging on large tables.
  • Apply Native Queries and Efficient Pagination — See native SQL and offset versus keyset paging on a news catalog, then build a monthly revenue report with PostgreSQL date_trunc and keyset-paginate a product list.
  • Understand Spring Data JPA Repositories — Explore Spring Data JPA repositories: choosing a base interface, derived query methods, @Query, projections, Specifications, and custom repository fragments.
  • Apply Spring Data JPA Repositories — Grow a task tracker's repository from derived methods to JPQL, native SQL, and paging, then query a product catalog four ways, ending with dynamic Specifications.
  • Understand Transaction Management — Take @Transactional apart: how Spring's proxy manages transactions, the self-invocation trap, propagation types, isolation levels, and rollback rules.
  • Apply Transaction Boundaries and Propagation — Watch a bank transfer commit, roll back, and audit with REQUIRES_NEW, then build an atomic placeOrder service whose audit record survives a rollback.
  • Understand Optimistic and Pessimistic Locking — Understand lost updates and other concurrency anomalies, and compare optimistic locking with @Version against pessimistic row locks, including SKIP LOCKED.
  • Apply Optimistic and Pessimistic Locking — Race two workers on one inventory row under each lock type, then protect a book inventory with @Version and retries, plus PESSIMISTIC_WRITE for the last copy.
  • Course Outro — Look back on everything you've built, from pooled JDBC connections to concurrency-safe persistence with JPA, Hibernate, and Spring Data JPA.
  • Transactional Banking Persistence Platform — Build the persistence layer of a small banking platform with Spring Boot 4, Hibernate 7, and PostgreSQL, handling concurrent transfers, audit trails, and large queries.

Taught by

Dr. Emma Seymour

Reviews

Start your review of Data Persistence with Hibernate and JPA

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.