AI Instructor Live Labs Included

Data Access with Spring Data JPA and PostgreSQL

Learn Spring Data JPA with PostgreSQL by building a Blog Platform backend. Covers entities, relationships, custom queries, transactions, Flyway migrations, and auditing.

Intermediate
19h 45m
14 Lessons
SMU-JAVA-JPA
Spring Data JPA and Database Integration Badge

View badge details

About This Course

Master production-grade data persistence in Java using Spring Data JPA and PostgreSQL. This course takes you from basic entity modeling through advanced topics including custom JPQL queries, optimistic locking, schema migrations with Flyway, and JPA auditing. You will incrementally build a complete Blog Platform backend, gaining hands-on experience with every major JPA pattern used in real-world Spring Boot applications.

Course Curriculum

14 Lessons
01
AI Lesson
AI Lesson

JPA Entities & Lifecycle

1h 0m

Learn what JPA is, how Hibernate implements it as the default provider in Spring Boot, and how entity objects move through the persistence lifecycle. Covers entity annotations, ID generation strategies, column constraints, and lifecycle callbacks.

02
Lab Exercise
Lab Exercise

JPA Entities - Lab Exercises

1h 45m 4 Exercises

Hands-on practice annotating the Author entity, creating AuthorRepository, implementing AuthorService, and verifying Hibernate creates the authors table in PostgreSQL.

Annotate the Author Entity ~15 min
Create the AuthorRepository ~15 min
Implement AuthorService and Wire AuthorController ~15 min
Verify Table Creation and Test with curl ~15 min
03
AI Lesson
AI Lesson

Entity Relationships

1h 0m

Learn how to model one-to-many, many-to-many, and one-to-one relationships between JPA entities. Covers FetchType, CascadeType, orphanRemoval, mappedBy, @JoinColumn, @JoinTable, and the N+1 query problem.

04
Lab Exercise
Lab Exercise

Entity Relationships - Lab Exercises

1h 45m 4 Exercises

Hands-on practice mapping Post, Tag, and Comment entities with @ManyToOne, @ManyToMany, and @OneToMany relationships in the Blog Platform.

Map Post with @ManyToOne and @ManyToMany ~15 min
Annotate the Tag Entity ~15 min
Annotate Comment with @ManyToOne to Post ~15 min
Add Inverse @OneToMany to Post and Verify Tables ~15 min
05
AI Lesson
AI Lesson

JPQL and Custom Queries

1h 0m

Learn JPQL vs native SQL, @Query annotation, named parameters, @Modifying, interface-based projections, DTO projections, Spring Data Specifications, and paginated custom queries.

06
Lab Exercise
Lab Exercise

Custom Queries - Lab Exercises

1h 45m 4 Exercises

Hands-on practice writing JPQL queries with @Query, building projections, and implementing native SQL full-text search in the Blog Platform.

Add JPQL Query to Find Posts by Author ~15 min
Implement Keyword Search Query ~15 min
Create PostSummary Projection and Top Commented Posts Query ~15 min
Add Native Full-Text Search and Wire All Queries ~15 min
07
AI Lesson
AI Lesson

Transactions and Concurrency

1h 0m

Learn ACID properties, @Transactional annotation, readOnly optimization, transaction propagation, rollback rules, optimistic locking with @Version, pessimistic locking, and why @Transactional does not work on private methods.

08
Lab Exercise
Lab Exercise

Transactions - Lab Exercises

1h 45m 4 Exercises

Hands-on practice adding @Version optimistic locking to Post, annotating PostServiceImpl with @Transactional, and testing concurrent edit conflicts.

Add @Version to Post Entity ~15 min
Annotate PostServiceImpl with @Transactional ~15 min
Handle ObjectOptimisticLockingFailureException in Controller ~15 min
Test Optimistic Locking with Concurrent Requests ~15 min
09
AI Lesson
AI Lesson

Schema Migration with Flyway

1h 0m

Learn why ddl-auto is unsafe for production, Flyway versioned migrations, naming convention, flyway_schema_history, baseline-on-migrate, and best practices for migration files.

10
Lab Exercise
Lab Exercise

Flyway Migrations - Lab Exercises

1h 45m 4 Exercises

Hands-on practice adding Flyway to the Blog Platform, creating versioned migration SQL files, and switching from ddl-auto=create to ddl-auto=validate.

Add Flyway Dependencies and Update application.properties ~15 min
Create Migration SQL Files V1 Through V3 ~15 min
Add V4 Migration for Post Excerpt Column ~15 min
Verify flyway_schema_history and Migration Integrity ~15 min
11
AI Lesson
AI Lesson

Auditing and Soft Deletes

1h 0m

Learn Spring Data JPA auditing with @EnableJpaAuditing, @CreatedDate, @LastModifiedDate, @CreatedBy, AuditorAware, @MappedSuperclass for shared audit fields, soft deletes with @SQLDelete and @SQLRestriction.

12
Lab Exercise
Lab Exercise

Auditing - Lab Exercises

1h 45m 4 Exercises

Hands-on practice creating AuditableEntity base class, enabling JPA auditing, adding soft delete to Post with @SQLDelete and @SQLRestriction, and creating Flyway migrations for audit columns.

Create AuditableEntity Base Class ~15 min
Configure JpaConfig with @EnableJpaAuditing ~15 min
Create Flyway Migration V5 for Audit Columns ~15 min
Add Soft Delete to Post with @SQLDelete and @SQLRestriction ~15 min
13
AI Lesson
AI Lesson

Capstone Briefing

1h 0m

Review all course concepts and walk through the capstone project requirements: implementing the Comment persistence layer with full CRUD, soft delete, and pagination for the Harborview Blog Platform.

14
Lab Exercise
Lab Exercise

Capstone Project

2h 15m 6 Exercises

Capstone: Implement the complete Comment service layer — create, paginated list, and soft delete — with Flyway migration and REST endpoints for the Blog Platform.

Complete V7 Migration for Comment Soft Delete ~15 min
Implement CommentService createComment ~15 min
Implement getCommentsByPost with Pagination ~15 min
Implement deleteComment and Wire CommentController ~15 min
End-to-End Comment API Test ~15 min
Stretch: Add Partial Index Migration V8 ~15 min

This course includes:

  • 24/7 AI Instructor Support
  • Live Lab Environments
  • 7 Hands-on Lessons
  • 6 Months Access
  • Completion Badge
  • Certificate of Completion
Spring Data JPA and Database Integration Badge

Earn Your Badge

Complete all lessons to unlock the Spring Data JPA and Database Integration achievement badge.

Category
Skill Level Intermediate
Total Duration 19h 45m
Spring Data JPA and Database Integration Badge
Achievement Badge

Spring Data JPA and Database Integration

Awarded for completing the Spring Data JPA course, demonstrating proficiency in database integration, JPA mapping, JPQL, and advanced persistence patterns.

Course Data Access with Spring Data JPA and PostgreSQL
Criteria Complete all lessons and pass assessments in the Spring Data JPA course.
Valid For 730 days

Skills You'll Earn

JPA Hibernate Spring Data Database Mapping JPQL Transaction Management

Complete all lessons in this course to earn this badge