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.
View badge details
About This Course
Course Curriculum
14 Lessons
JPA Entities & Lifecycle
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.
JPA Entities - Lab Exercises
Hands-on practice annotating the Author entity, creating AuthorRepository, implementing AuthorService, and verifying Hibernate creates the authors table in PostgreSQL.
Entity Relationships
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.
Entity Relationships - Lab Exercises
Hands-on practice mapping Post, Tag, and Comment entities with @ManyToOne, @ManyToMany, and @OneToMany relationships in the Blog Platform.
JPQL and Custom Queries
Learn JPQL vs native SQL, @Query annotation, named parameters, @Modifying, interface-based projections, DTO projections, Spring Data Specifications, and paginated custom queries.
Custom Queries - Lab Exercises
Hands-on practice writing JPQL queries with @Query, building projections, and implementing native SQL full-text search in the Blog Platform.
Transactions and Concurrency
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.
Transactions - Lab Exercises
Hands-on practice adding @Version optimistic locking to Post, annotating PostServiceImpl with @Transactional, and testing concurrent edit conflicts.
Schema Migration with Flyway
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.
Flyway Migrations - Lab 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.
Auditing and Soft Deletes
Learn Spring Data JPA auditing with @EnableJpaAuditing, @CreatedDate, @LastModifiedDate, @CreatedBy, AuditorAware, @MappedSuperclass for shared audit fields, soft deletes with @SQLDelete and @SQLRestriction.
Auditing - Lab 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.
Capstone Briefing
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.
Capstone Project
Capstone: Implement the complete Comment service layer — create, paginated list, and soft delete — with Flyway migration and REST endpoints for the Blog Platform.