Mô tả

This course supports both Spring Boot 2 and Spring Boot 3.

In this course, you will learn how to use Spring Data JPA and its features to reduce a lot of boilerplate code.


Throughout this course, we will build domain model entities (Product, ProductCategory, Order, OrderItems, User, Roles) and repositories for a simple e-commerce application.


Problem:

In typical three-layer Spring boot application architecture, we create three layers - Controller, Service, and DAO/Repository layer.

If we use JPA/Hibernate and then write a lot of coding while implementing DAO/Repository layer - We repeat the same code again and again so what will be the solution to reduce the boilerplate code?

Solution:

Spring Data JPA provides a solution to reduce a lot of boilerplate code.

We can use Spring Data JPA to reduce the amount of boilerplate code required to implement the data access object (DAO) layer.

Spring Data JPA is not a JPA provider. It is a library/framework that adds an extra layer of abstraction on top of our JPA provider (like Hibernate). Spring Data JPA uses Hibernate as a default JPA provider.

What you'll learn

  • Learn How to Use Spring Data JPA in the Spring Boot Application

  • Learn How to Use JPA Annotations to Create an Entity and Map to a Database Table

  • Learn 4 Types of Primary key Generation Strategies - AUTO, IDENTITY, SEQUENCE, and TABLE

  • Learn How to Use the Lombok Library to Reduce a Boilerplate Code

  • Learn Spring Data JPA Repository Interfaces and Its Hierarchy

  • Learn Steps to Use Spring Data JPA Repository

  • Learn Important Spring Data JPA Repository Methods (CRUD Operations)

  • Learn How to Create Query Methods or Finder Methods Using Method Names

  • Learn How to Create JPQL and Native SQL Queries Using @Query Annotation

  • Learn How to Create JPQL and Native SQL Queries With Named Queries

  • Learn How to Implement Pagination and Sorting Using Spring Data JPA

  • Learn JPA/Hibernate One-to-One Mapping Using Spring Data JPA

  • Learn JPA/Hibernate One to Many Mapping Using Spring Data JPA

  • Learn JPA/Hibernate Many to Many Mapping Using Spring Data JPA

  • Learn JPA Cascade Types and Fetch Types (EAGER and LAZY)

  • Learn building domain model relationships for e-commerce projects using Hibernate ORM framework

  • Learn to implement Search/Filter functionality

  • Learn Transaction Management with Spring Data JPA and Spring Boot

  • Unit Testing Spring Data JPA Repository using @DataJpaTest annotation


Tools and Technologies used

Technologies:

- Java 11+

- Spring Boot

- Spring Data JPA

- Hibernate

- Lombok

- Maven

- JUnit framework

IDE:

- IntelliJ IDEA

Database:

- MySQL database

Bạn sẽ học được gì

Learn How to Use Spring Data JPA in the Spring Boot Application

Build Domain Model Relationships for E-commerce Project Using Hibernate ORM Framework

Learn How to Use JPA Annotations to Create an Entity and Map to a Database Table

Learn 4 Types of Primary key Generation Strategies - AUTO, IDENTITY, SEQUENCE, and TABLE

Learn How to Use the Lombok Library to Reduce a Boilerplate Code

Learn Spring Data JPA Repository Interfaces and Its Hierarchy

Learn Steps to Use Spring Data JPA Repository

Learn Important Spring Data JPA Repository Methods (CRUD Operations)

Learn How to Create Query Methods or Finder Methods Using Method Names

Learn How to Create JPQL and Native SQL Queries Using @Query Annotation

Learn How to Create JPQL and Native SQL Queries With Named Queries

Learn How to Implement Pagination and Sorting Using Spring Data JPA

Learn JPA/Hibernate One to One Mapping Using Spring Data JPA

Learn JPA/Hibernate One to Many Mapping Using Spring Data JPA

Learn JPA/Hibernate Many to Many Mapping Using Spring Data JPA

Learn JPA Cascade Types and Fetch Types (EAGER and LAZY)

Learn to implement Search/Filter Functionality

Learn Transaction Management with Spring Data JPA and Spring Boot

Unit Testing Spring Data JPA Repository using @DataJpaTest annotation

Yêu cầu

  • Java
  • Good to know Spring Boot Basics
  • Basic Understanding of JPA and Hibernate
  • Basic Understanding of SQL

Nội dung khoá học

17 sections

Introduction

5 lectures
Course Introduction
08:05
How to Get Help
00:47
My Other Top and Bestseller Udemy Courses - Don't Skip
01:39
Download Source Code and PDF Files (Class Notes)
00:23
Update on Using Spring Boot 3
00:49

Setting Up Your Development Environment

6 lectures
Guide to Setup Development Environment
01:24
Install Java JDK 18 on Windows 10
05:56
Install IntelliJ IDEA in Windows 10 - IntelliJ Community (FREE) Edition
09:47
Install and Setup Spring Tool Suite 4 (STS) in Windows 10 - For STS Users
09:23
Install Lombok in Eclipse STS (Spring Tool Suite) IDE - For STS Users
10:54
Install MySQL Server 8 and MySQL Workbench in Windows 10
13:04

Getting Started with Spring Data JPA

7 lectures
What is ORM?
03:24
What is JPA?
05:38
What is Hibernate?
04:03
JPA vs Hibernate
02:46
What is Spring Data JPA?
06:28
Basic Flow of Spring Data JPA
03:48
Hibernate vs Spring Data JPA
04:46

Create and Setup Spring Boot Project with Spring Data JPA

11 lectures
Use Spring Boot 3 and Java 17+
00:08
Create and Setup Spring Boot Project in IntelliJ IDEA
06:34
Understanding Spring Boot Starter Data JPA Dependency
04:17
Connect Spring Boot Application with MySQL Database
11:16
Create Product Entity with @Entity and @Id
08:03
Using JPA Annotations - @Table, @Column, @GeneratedValue and @UniqueConstraint
11:59
Primary key generation strategies - AUTO, IDENTITY, SEQUENCE and TABLE
14:23
Adding Hibernate annotations - @CreationTimestamp and @UpdateTimestamp
02:35
Using Lombok Library to Reduce Boilerplate Code
04:44
Download Source Code of this Section
00:11
Quiz Time
6 questions

Spring Data JPA Repository Interfaces and It’s Hierarchy

6 lectures
Understanding Spring Data JPA Repository Interfaces and it’s Hierarchy
07:09
FAQ on SimpleJpaRepository
01:05
Decompile Spring Data JPA Library to Understand Repository Interfaces
07:28
Steps to Create Spring Data JPA Repository - ProductRepository
06:02
Download Source Code of this Section
00:11
Quiz Time
3 questions

Important Spring Data JPA Repository Methods

13 lectures
Overview of Spring Data JPA Repository Methods
03:50
save() - Save an Entity to the Database Table
12:15
save() - Update an Entity to the Database Table
06:23
findById() - Retrieve a Single Entity from the Database
03:54
saveAll() - Save Multiple Entities to the Database Table
06:18
findAll() - Retrieve All the Entities From the Database Table
04:14
deleteById() - Delete a Single Entity from the Database
03:43
delete() - Delete an Entity From the Database Table
07:05
deleteAll() - Delete All the Entities From the Database Table
09:59
count() - Get the Number of Records in the Database Table
03:31
existsById() - Check if Entity Exists With Given ID in the Database Table
05:45
Download Source Code of this Section
00:11
Quiz Time
3 questions

Query Methods or Finder Methods

16 lectures
Overview of Creating Query Methods From Method Names Strategy
02:43
How Query Generation From Method Names Works Behind the Scene
05:08
Understanding Rules and Supported Keywords to Create Query Methods
12:42
Spring Data JPA Query Method - Find by Single Field Name
13:13
Spring Data JPA Query Method - Find by Multiple Field Names
12:38
Spring Data JPA Query Method - Find by Distinct
04:41
Spring Data JPA Query Method - Find by GreaterThan
05:48
Spring Data JPA Query Method - Find by LessThan
05:01
Spring Data JPA Query Method - Find by Containing
05:11
Spring Data JPA Query Method - Find by Like
05:43
Spring Data JPA Query Method - Find by Between (Price Range Example)
06:16
Spring Data JPA Query Method - Find by Between (Date Range Example)
08:48
Spring Data JPA Query Method - Find by In
05:27
Spring Data JPA Query Method - Limiting Query Results
07:02
Download Source Code of this Section
00:11
Quiz Time
5 questions

JPQL and Native SQL Queries using @Query Annotation

7 lectures
Understanding @Query Annotation
05:14
Creating JPQL Query with Index Parameters using @Query
09:14
Creating JPQL Query with Named Parameters using @Query
07:44
Creating Native SQL Query with Index Parameters using @Query
09:40
Creating Native SQL Query with Named Parameters using @Query
06:55
Download Source Code of this Section
00:11
Quiz Time
3 questions

Creating Named Queries

6 lectures
Creating Named JPQL Query using @NamedQuery Annotation
13:25
Creating Multiple Named JPQL Queries using @NamedQueries Annotation
08:28
Creating Named SQL Query using @NamedNativeQuery Annotation
08:14
Creating Multiple Named SQL Queries using @NamedNativeQueries Annotation
06:32
Download Source Code of this Section
00:11
Quiz Time
4 questions

Pagination and Sorting

7 lectures
Understanding Spring Data JPA Pagination and Sorting
09:18
Spring Data JPA - Pagination Implementation
14:53
Spring Data JPA - Sorting Implementation
09:51
Spring Data JPA - Implement Sorting with Multiple Fields
07:27
Spring Data JPA - Implement Paging and Sorting Together
09:37
Download Source Code of this Section
00:11
Quiz Time
4 questions

One to One Mapping (@OneToOne)

11 lectures
One-To-One Mapping Overview
04:35
Unidirectional One-To-One Mapping Overview
06:40
Create Order and Address Entities
09:09
Establish Unidirectional One-To-One Mapping
04:46
Create OrderRepository and AddressRepository
03:31
Understanding JPA Cascade Types
09:13
Test Unidirectional One-To-One Mapping (CRUD Operations)
17:36
Bidirectional One-To-One Mapping
05:56
Establish Bidirectional One-To-One Mapping
03:43
Test Bidirectional One-To-One Mapping (CRUD Operations)
11:16
Download Source Code of this Section
00:11

One to Many Mapping (@OneToMany and @ManyToOne)

9 lectures
One to Many Mapping Overview
02:55
Unidirectional One-To-Many Mapping Overview
04:46
Create OrderItem Entity and Establish Unidirectional One-To-Many Mapping
10:28
Fetch Types - Eager vs Lazy
04:52
Test One-To-Many Unidirectional Mapping (CRUD Operations) - Part 1
14:49
Test One-To-Many Unidirectional Mapping (CRUD Operations) - Part 2
06:51
Bidirectional One-To-Many Mapping Overview
04:29
Bidirectional One-To-Many Mapping Between Order and OrderItem
09:06
Download Source Code of this Section
00:11

One to Many Mapping (ProductCategory and Product)

4 lectures
One-To-Many Mapping Between Product and ProductCategory
10:10
Testing One-To-Many Mapping (Save Operation)
09:21
FetchType.Lazy Demonstration
05:49
Download Source Code of this Section
00:11

Many to Many Mapping (@ManyToMany)

10 lectures
Many to Many Mapping Overview
03:44
Unidirectional Many-To-Many Mapping Overview
05:08
Create User and Role Entities
05:42
Establish Unidirectional Many-To-Many Mapping Between User and Role
08:15
Create UserRepository and RoleRepository
02:16
Test Unidirectional Many-To-Many Mapping (CRUD Operations)
15:41
Bidirectional Many-To-Many Mapping Overview
02:14
Establish Bidirectional Many-To-Many Mapping Between User and Role
03:06
Test Bidirectional Many-To-Many Mapping
08:43
Download Source Code of this Section
00:11

Implementing the Search Functionality

8 lectures
Create Spring Boot Project
06:11
Configure MySQL Database
05:20
Create Product JPA Entity
04:44
Create ProductRepository Interface
02:30
Create JPQL and Native SQL queries for Search REST API
05:24
Create Service Layer
03:01
Build Search REST API and Test using Postman
10:09
Download Source Code of this Section
00:04

Transaction Management with Spring Data JPA (Spring Boot)

12 lectures
Module Intro - What You Will Learn in This Section?
01:13
Transaction Management with Spring Data JPA
07:00
Use Case - Placing Order on eCommerce Shopping Website
03:17
Create and Setup Spring Boot Project in IntelliJ
06:43
Configure MySQL Database
05:19
Create Order and Payment JPA Entities
08:10
Create OrderRepository and Payment Repository Interfaces
02:27
Create OrderRequest and OrderResponse DTO Classes
02:27
Create Service Layer
09:34
Create Place Order REST API and Test using Postman
06:36
Handle Transaction using Spring @Transactional Annotation
06:32
Download Source Code of this Section
00:04

Unit Testing Spring Data JPA Repository layer - @DataJpaTest

18 lectures
Repository Layer Unit Testing Overview
04:34
@DataJpaTest Annotation
05:38
Create and Setup Spring Boot project in IntelliJ IDEA
08:11
Understanding Spring boot Starter Test Dependency
06:07
Create JPA Entity
08:58
Create Spring Data JPA Repository
05:01
Unit Test for Save Employee Operation
16:04
Unit Test for Get All Employees Operation
09:46
Unit Test for Get Employee by ID Operation
04:54
Unit Test for Get Employee by Email Operation (Spring Data JPA Query Method)
07:07
Unit Test for Update Employee Operation
10:00
Unit Test for Delete Employee Operation
04:54
Unit Test Spring Data JPA Custom Query Method Using JPQL With Index Param
09:33
Unit Test Spring Data JPA Custom Query Method Using JPQL With Named Param
05:36
Unit Test Spring Data JPA Custom Native Query With Index Parameters
08:56
Unit Test Spring Data JPA Custom Native Query With Named Parameters
03:35
Refactoring JUnit Tests to Use @BeforeEach Annotation
05:10
Download Source Code of this Section
00:04

Đánh giá của học viên

Chưa có đánh giá
Course Rating
5
0%
4
0%
3
0%
2
0%
1
0%

Bình luận khách hàng

Viết Bình Luận

Bạn đánh giá khoá học này thế nào?

image

Đăng ký get khoá học Udemy - Unica - Gitiho giá chỉ 50k!

Get khoá học giá rẻ ngay trước khi bị fix.