Master Hibernate and JPA with Spring Boot in 100 Steps

Video description

Hibernate is the most popular implementation of JPA. It was the most popular ORM framework option before JPA emerged and it provides additional features on top of JPA. We will use Hibernate as the JPA implementation in this course.

The Java Persistence API provides Java developers with an API to map Java objects to relational data. In this course, you will learn about Hibernate, JPA API, JPQL (Java Persistence query language), Java Persistence Criteria API, and how you can perform ORM (Object Relational Mapping) with JPA and Hibernate.

In this course, you will learn the basics of JPA and Hibernate such as entities, relationships, inheritance mappings, and annotations. Understand approaches to querying data using JPA and Hibernate (JPQL, Criteria API, and Native Queries). Understand JPA and Hibernate Relationships in-depth such as one to one, many to one, and many to many.

Use a variety of Spring Boot Starters such as Spring Boot Starter Web, Starter Data JPA, and Starter Test. Learn the basics of performance tuning your JPA application with Hibernate - Solve N+1 Queries Issue. Learn the basics of caching such as first-level cache and second-level cache with EhCache. Understand the basics of Spring Data JPA and Spring Data REST.

By the end of this course, you will become a master in Hibernate and JPA with Spring Boot.

What You Will Learn

  • Learn the basics of JPA and Hibernate such as entities, relationships, inheritance mapping, and annotation
  • Approaches to querying data using JPA and Hibernate such as JPQL, Criteria API, and Native Queries
  • Understand JPA and Hibernate relationships in-depth such as one to one, many to one, and many to many
  • Learn the basic of performance tuning your JPA application with Hibernate - Solve N+1 Queries Issue
  • Learn the basics of caching such as first-level cache and second-level cache with EhCache
  • Understand the basics of Spring Data JPA and Spring Data REST

Audience

This course is for anyone who wants to learn the basics of JPA and Hibernate and understand how to build the data layer of a web application.

About The Author

In28Minutes Official: Ranga Karanam is a seasoned technologist and architect with over two decades of expertise in programming, design, and architecture. He founded in28Minutes with the goal of helping students master cutting-edge cloud-native technologies such as AWS, Azure, Google Cloud, Docker, and Kubernetes. With 15 years of experience in Java programming and design, Ranga has collaborated with top banking clients worldwide.

His passion for creating hands-on courses with real-world projects motivated him to develop the Step-By-Step series of courses that follow a problem-solution-based approach, with practical and real-world application examples.

Ranga and his team at in28Minutes specialize in Java and related frameworks such as Spring, Spring Boot, Spring MVC, Struts, and Hibernate. They are committed to equipping learners with the skills and knowledge necessary to succeed in today’s rapidly evolving technology landscape.

Table of contents

  1. Chapter 1 : Introduction
    1. Master Hibernate and JPA with Spring Boot
    2. Master Hibernate and JPA with Spring Boot - Course Overview
    3. Master Hibernate and JPA with Spring Boot - Git Repository
    4. Master Hibernate and JPA with Spring Boot - Installing Basic Tools
    5. Quick Introduction to JPA
  2. Chapter 2 : Introduction to Spring Boot in 10 Steps
    1. Introduction to Spring Boot in 10 Steps
    2. Step 1: Introduction to Spring Boot - Goals and Important Features
    3. Step 2: Developing Spring Applications before Spring Boot
    4. Step 3: Using Spring Initializr to Create a Spring Boot Application
    5. Step 4: Creating a Simple REST Controller
    6. Step 5: What is Spring Boot Auto Configuration?
    7. Step 6: Spring Boot Versus Spring Versus Spring MVC
    8. Step 7: Spring Boot Starter Projects - Starter Web and Starter JPA
    9. Step 8: Overview of Different Spring Boot Starter Projects
    10. Step 9: Spring Boot Actuator
    11. Step 10: Spring Boot Developer Tools
  3. Chapter 3 : Journey From Spring JDBC to JPA
    1. Introduction to Journey from JDBC To JPA
    2. Step 01 - Setting Up a Project with JDBC, JPA, H2, and Web Dependencies
    3. Step 02 - Launching Up H2 Console
    4. Step 03 - Creating a Database Table in H2
    5. Step 04 - Populate Data into Person Table
    6. Step 05 - Implement findAll persons Spring JDBC Query Method
    7. Step 06 - Execute the findAll Method using CommandLineRunner
    8. Step 07 - A Quick Review - JDBC Versus Spring JDBC
    9. Step 08 – What’s in the background? Understanding Spring Boot Autoconfiguration
    10. Step 09 - Implementing findByID Spring JDBC Query Method
    11. Step 10 - Implementing deleteByID Spring JDBC Update Method
    12. Step 11 - Implementing Insert and Update Spring JDBC Update Methods
    13. Step 12 - Creating a Custom Spring JDBC RowMapper
    14. Step 13 - Quick Introduction to JPA
    15. Step 14 - Defining Person Entity
    16. Step 15 - Implementing findByID JPA Repository Method
    17. Step 16 - Implementing Insert and Update JPA Repository Methods
    18. Step 17 - Implementing deleteByID JPA Repository Method
    19. Step 18 - Implementing findAll Using JPQL Named Query
  4. Chapter 4 : Introduction to JUnit in 5 Steps
    1. Introduction to JUnit in 5 Steps
    2. Step 1: What is JUnit and Unit Testing?
    3. Step 2: First JUnit Project and Green Bar
    4. Step 3: First Code and First Unit Test
    5. Step 4: Other Assert Methods
    6. Step 5: Important Annotations
  5. Chapter 5 : JPA and Hibernate in Depth
    1. Introduction to JPA and Hibernate in Depth
    2. Step 01 - Create a JPA Project with H2 and Spring Boot
    3. Step 02 - Create JPA Entity Course
    4. Step 03 - Create findByID Using JPA Entity Manager
    5. Step 04 - Configuring Application Properties to Enable H2 Console and Logging
    6. Step 05 - Writing Unit Test for the findByID Method
    7. Step 06 - Writing a deleteByID Method to Delete an Entity
    8. Step 07 - Writing Unit Test for the deleteByID Method
    9. Step 08 - Writing a Save Method to Update and Insert an Entity
    10. Step 09 - Writing Unit Test for the save Method
    11. Step 10 - Quick Review and Debugging Tips
    12. Step 11 - Playing with Entity Manager
    13. Step 12 - Entity Manager Methods - clear and detach
    14. Step 13 - Entity Manager Methods – refresh
    15. Step 14 - A Quick Review of Entity Manager
    16. Step 15 - JPQL – Basics
    17. Step 16 - JPA and Hibernate Annotations - @Table
    18. Step 17 - JPA and Hibernate Annotations - @Column
    19. Step 18 - JPA and Hibernate Annotations - @UpdateTimestamp and @CreationTimestamp
    20. Step 19 - JPA and Hibernate Annotations - @NamedQuery and @NamedQueries
    21. Step 20 - Native Queries – Basics
  6. Chapter 6 : Establishing Relationships with JPA and Hibernate – OneToOne
    1. Step 21 - Entities and Relationships - an Overview
    2. Step 22 - Defining Entities - Student, Passport, and Review
    3. Step 23 - Introduction to One to One Relationship
    4. Step 24 - OneToOne Mapping - Insert Student with Passport
    5. Step 25 - OneToOne Mapping - Retrieving Student with Passport and Eager Fetch
    6. Step 26 - OneToOne Mapping - Lazy Fetch
    7. Step 27 - Transaction, Entity Manager, and Persistence Context
    8. Step 28 - OneToOne Mapping - Bidirectional Relationship - Part 1
    9. Step 29 - OneToOne Mapping - Bidirectional Relationship - Part 2
  7. Chapter 7 : Review with a Few FAQs about Hibernate and JPA
    1. FAQ 1 - When does Hibernate send updates to the database?
    2. FAQ 2 - When do We Need @Transactional in a Unit Test?
    3. FAQ 3 – Do Read Only Methods Need a Transaction?
    4. FAQ 4 - Why do We Use @DirtiesContext in a Unit Test?
  8. Chapter 8 : Establishing Relationships with JPA and Hibernate - OneToMany and ManyToMany
    1. Step 30 - ManyToOne Mapping - Designing the Database
    2. Step 30 - Part 2 - ManyToOne Mapping - Implementing the Mapping
    3. Step 31 - ManyToOne Mapping - Retrieving and Inserting Reviews for Course
    4. Step 32 - ManyToOne Mapping - Generalizing Insert Reviews
    5. Step 33 - ManyToOne Mapping - Wrapping Up
    6. Step 34 - ManyToMany Mapping - Table Design
    7. Step 35 - ManyToMany Mapping - Adding Annotations on Entities
    8. Step 36 - ManyToMany Mapping - Fixing Two Join Tables Problem
    9. Step 37 - ManyToMany Mapping - Customizing the Join Table
    10. Step 38 - ManyToMany Mapping - Insert Data and Write Join Query
    11. Step 39 - ManyToMany Mapping - Retrieve Data Using JPA Relationships
    12. Step 40 - ManyToMany Mapping - Insert Student and Course
    13. Step 41 - Relationships between JPA Entities - a Summary
  9. Chapter 9 : Inheritance Hierarchies with JPA and Hibernate
    1. Step 42 - Introduction to Inheritance Hierarchies and Mappings
    2. Step 43 - JPA Inheritance Hierarchies and Mappings - Setting Up Entities
    3. Step 44 - JPA Inheritance Hierarchies and Mappings - Setting Up a Repository
    4. Step 45 - JPA Inheritance Hierarchies and Mappings - Single Table
    5. Step 46 - JPA Inheritance Hierarchies and Mappings - Table Per Class
    6. Step 47 - JPA Inheritance Hierarchies and Mappings – Joined
    7. Step 48 - JPA Inheritance Hierarchies and Mappings - Mapped Super Class
    8. Step 49 - JPA Inheritance Hierarchies and Mappings - How to Choose?
  10. Chapter 10 : Queries with Entities using JPQL
    1. Step 50 - JPQL - Courses Without Students
    2. Step 51 - JPQL - Courses with 2 Students and order by
    3. Step 52 - JPQL - Courses Like 100 Steps
    4. Step 53 - JPQL - Using Joins
  11. Chapter 11 : Queries using Java API - Criteria Queries
    1. Step 54 - Criteria Query - Retrieving All Courses
    2. Step 55 - Criteria Query - Courses Like 100 Steps
    3. Step 56 - Criteria Query - Courses Without Students
    4. Step 57 - Criteria Query - Using Joins
  12. Chapter 12 : Transaction Management
    1. Step 58 - Introduction to Transaction Management
    2. Step 59 - Transaction Management - ACID Properties
    3. Step 60 - Understanding Dirty, Phanthom, and Non-Repeatable Reads
    4. Step 61 - Understand 4 Isolation Levels
    5. Step 62 - Choosing Between Isolation Levels
    6. Step 63 - Implementing Transaction Management - 3 Things to Decide
  13. Chapter 13 : Spring Data JPA and Spring Data REST
    1. Step 64 - Introduction to Spring Data JPA
    2. Step 65 - Testing the Spring Data JPA Repository with findByID.
    3. Step 66 - Spring Data JPA Repository - CRUD Methods
    4. Step 67 - Sorting Using Spring Data JPA Repository
    5. Step 68 - Pagination Using Spring Data JPA Repository
    6. Step 69 - Custom Queries Using Spring Data JPA Repository
    7. Step 70 - Spring Data REST
  14. Chapter 14 : Caching with Hibernate and JPA
    1. Step 71 - Introduction to Caching and the Various Levels of Caching in Hibernate and JPA
    2. Step 72 - Hibernate and JPA Caching – First-Level Cache
    3. Step 73 - Hibernate and JPA Caching - Basics of Second-Level Cache with EhCache
    4. Step 74 - Hibernate and JPA Caching – Second-Level Cache Part 2
  15. Chapter 15 : Hibernate and JPA Tips
    1. Step 75 - Hibernate Tips - Hibernate Soft Deletes - @SQLDelete and @Where
    2. Step 76 - Hibernate Soft Deletes - Part 2
    3. Step 77 - JPA Entity Life Cycle Methods
    4. Step 78 - Using Embedded and Embeddable with JPA
    5. Step 79 - Using Enums with JPA
    6. Step 80 - JPA Tip - Be Cautious with toString Method Implementations
    7. Step 81 - JPA Tip - When do You Use JPA?
  16. Chapter 16 : Performance Tuning Tips with Hibernate and JPA
    1. Step 82 - Performance Tuning - Measure Before Tuning
    2. Step 83 - Performance Tuning – Indexes
    3. Step 84 - Performance Tuning - Use Appropriate Caching
    4. Step 85 - Performance Tuning - Eager Versus Lazy Fetch
    5. Step 86 - Performance Tuning - Avoid N+1 Problems
  17. Chapter 17 : A Few More FAQs
    1. FAQ 5 - How to Connect to a Different Database with Spring Boot?
    2. FAQ 6 - Approach to Design Great Applications with JPA?
    3. FAQ 7 - Good Practices for Developing JPA Applications
  18. Chapter 18 : Congratulations
    1. Congratulations
  19. Chapter 19 : Appendix - Introduction to Spring Framework in 10 Steps
    1. Introduction to Spring Framework in 10 Steps
    2. Step 1 - Setting up a Spring Project Using htttp://start.spring.io
    3. Step 2 - Understanding Tight Coupling Using the Binary Search Algorithm Example
    4. Step 3 - Making the Binary Search Algorithm Example Loosely Coupled
    5. Step 4 - Using Spring to Manage Dependencies - @Component, @Autowired
    6. Step 5 - What is Happening in the Background?
    7. Step 6 - Dynamic auto wiring and Troubleshooting - @Primary
    8. Step 7 - Constructor and Setter Injection
    9. Step 8 - Spring Modules
    10. Step 9 - Spring Projects
    11. Step 10 - Why is Spring Popular?

Product information

  • Title: Master Hibernate and JPA with Spring Boot in 100 Steps
  • Author(s): In28Minutes Official
  • Release date: March 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788995320