inflearn logo

High-Performance Spring Persistence

This course covers the next level of JPA performance optimization beyond Fetch Join and batch_fetch_size. From JPA to Hibernate, JDBC, and the DB engine—you will understand the underlying operational principles and learn seven strategies that can create an 18x performance difference with a single line of configuration. Moving beyond Read optimization, you will tune the entire Spring Persistence layer, including Write performance, relationship pitfalls, and production testing environments. Vlad Mihalcea, a Java Champion and core Hibernate contributor, teaches based on his experience and the tools he personally created to overcome the limitations of Spring Data JPA.

(5.0) 2 reviews

105 learners

Level Intermediate

Course period Unlimited

Java
Java
Spring
Spring
JPA
JPA
database
database
hibernate
hibernate
Java
Java
Spring
Spring
JPA
JPA
database
database
hibernate
hibernate

What you will gain after the course

  • Learn how to remove unnecessary SELECT statements and improve bulk INSERT performance by more than 10 times.

  • Learn strategies to maintain a consistent query speed regardless of the number of pages, even with millions of data records.

  • Experience the 18x performance gap created by a single line of configuration through benchmark figures from 4 different databases.



Learn from a Global Java Champion

High-Performance Spring Persistence Lecture


A high-performance data access layer must be in perfect sync with the underlying database.
Beyond JPA to Hibernate, JDBC, and the DB — this is a journey to optimize the entire data access layer.


Have you ever experienced this?


→ JpaRepository.saveAll()Have you ever discovered it firing unnecessary SELECT queries for every single entity?

→ @DynamicUpdate What about the experience where enabling it actually degraded performance?

→ Don't know why OFFSET-based pagination gets 20 times slower as you go further back?

→ Did you know that a single line of configuration can make a difference of 550ms → 30ms (18x improvement) when querying 100,000 records?

JPA is just the tip of the iceberg
The core is 'below the surface'


To ensure the data access layer works in harmony with the DB,
you must understand the underlying principles of Hibernate, JDBC, and the database engine.

This difference is what separates a high-performance application from one that barely runs.



What you will learn in this course

7 Optimization Strategies to Master Spring Performance


From entity mapping to batch processing, relationship pitfalls, lazy loading, and test environments
— learn the core strategies for Spring Persistence performance tuning.


Data Model and Identifier Design with Performance in Mind

Many developers focus only on adding the @Id annotation, but the choice of identifier strategy determines write performance. save() explains why a SELECT query is executed even for a new entity and why certain ID strategies prevent batch processing.

Before

Commonly used ID strategies + save()
→ Batch INSERT impossible, INSERTs performed one by one per entity

After

By changing the ID strategy and storage method,
→ process bulk INSERTs at once with JDBC batching


Operating Principles of Persistence Context and Flush Mechanism

"Why are there so many unintended UPDATE queries?" — We no longer leave the 'timing of SQL execution' to guesswork. We analyze the internal workings of Dirty Checking and @DynamicUpdate learn the true criteria for using it.

Before

@DynamicUpdate indiscriminate use
→ can actually cause other performance issues

After

Decision criteria for each situation established
→ Eliminate unnecessary UPDATEs + Maintain cache


JDBC Batch Processing and Statement Caching

If you repeatedly call save() inside a for loop, you will face terrible performance degradation even with just over 10,000 records. We will go beyond the limitations that cannot be solved by JPA's default behavior alone and apply JDBC batch processing and statement caching in practice.

Before

saveAll() executes individual
SELECT + INSERT statements for each entity

After

Replace Save Method+ JDBC Batching
→ 0 SELECTs + Batch INSERT


Fetch strategy to avoid N+1

Did you think solving N+1 with fetch joins was the end of it? There are areas that fetch joins cannot solve. You will experience a 18-fold difference in bulk query performance with just a single configuration value.

Before

Retrieving 100,000 records with default Fetch Size
→ Takes 550ms

After

Add one line of configuration
→ Takes 30ms (18x improvement)


Pagination and Projection for Large-Scale Lookups

"The memory exploded after querying all the data." — We acknowledge the fundamental limitations of OFFSET and implement an alternative in a Spring Data environment that maintains a consistent speed regardless of the page number. You will also learn projection techniques to select only the necessary columns.

Before

OFFSET-based pagination
→ becomes 20 times slower as you go further back

After

By replacing OFFSET
→ Consistent response speed on any page


Performance Pitfalls of Relationship Mapping

Setting up relationships is not difficult, but depending on the mapping method, unnecessary tables may be created or Lazy Loading may be ignored. Learn about the performance pitfalls of relationships frequently encountered in practice and their solution patterns.

Before

In certain association mappings, Lazy loading is ignored
→ resulting in unnecessary tables + additional SELECT queries

After

Switching mapping patterns to
→ remove unnecessary tables + ensure Lazy loading works correctly


Production DB-based Performance Testing

Even if tests pass with H2, the results can be completely different in the production DB. Learn test strategies to verify performance optimization in an actual DB environment.

Before

Testing with H2 in-memory DB
→ Performance issues discovered too late in production

After

Same DB as Production Testing
→ Pre-verify performance issues before deployment


If you've already tried fetch joins, this is where you begin.

Add the subtle details that set the fundamentals apart and perfect your performance optimization.

The optimizations we usually do

  • N+1 queries
    Fetch Join

  • Collection Paging
    default_batch_fetch_size with IN queries

  • DTO Projection
    JPQL new constructor expression

  • Bulk INSERT
    Not covered

  • save() overhead
    Not covered

  • @DynamicUpdate
    Not covered

  • Relationship Traps
    Not covered

  • Production DB Testing
    Not covered




Vlad's High-Performance Spring

  • N+1 Queries
    Advanced strategies beyond Fetch Join for an 18x improvement

  • Collection Paging
    Maintaining a consistent speed regardless of the number of pages

  • DTO Projection
    Spring Data-exclusive lightweight retrieval techniques

  • Bulk INSERT
    By changing settings and strategies, enable Batch INSERT

  • save() overhead
    Completely eliminate unnecessary SELECTs occurring for every entity

  • @DynamicUpdate
    When to turn it on vs. when to turn it off, providing decision criteria

  • Relationship Traps
    Lazy loading failures, unnecessary table creation, and more—solving real-world pitfalls

  • Production DB Testing
    Pre-deployment verification in an environment identical to production

The person who created this course

An expert trusted by developers worldwide
Vlad Mihalcea


  • Author of the JPA performance textbook, "High-Performance Java Persistence" (Amazon rating 4.7)

  • 2017, Selected as 'Java Champion' by Oracle

  • Participated in establishing the Java Persistence API (JPA) 2.1 standard (JSR 338 Expert Group)

  • Stack Overflow Top 0.1% Contributor

  • Developed Hypersistence Optimizer

  • JPA performance consultant for numerous global top-tier IT companies


Vlad is not just an expert who knows Hibernate well.
He is the person who personally created an alternative library to overcome the performance limitations of Spring Data JPA.
In this course, you will learn directly from him why he created this tool and what problems it solves.


Check out the testimonials from Java Champions around the world!


Rafael Winterhalter
(Creator of Byte Buddy
Java Champion)

Lukas Eder
(Founder of jOOQ
Java Champion)

Markus Eisele
(Red Hat Technology Evangelist
Java Champion)

Whether you use JDBC directly or through JPA or Hibernate, there is no better resource that summarizes the performance impact than this.

This book is a must-read for any developer looking to push the performance of relational databases to the limit with JAVA applications.

Vlad has distilled his vast experience into an easy-to-read book, and it is a must-read for anyone working with JPA or Hibernate.



🎉 Special EVENT to Celebrate the Launch of Our New Course 🎉

To celebrate the launch of the High-Performance Spring Persistence course, we are holding a limited-time discount event for all courses!

Benefit 1) 40% discount on individual courses
High-Performance JPA & Hibernate
High-Performance SQL for JPA (ORM) Developers
---

Benefit 2) 50% discount when purchasing as a roadmap
World Java Champion, Vlad Mihalcea Lecture Roadmap

Notes before taking the course

Currently, the final section, 'Fetching Optimization', is being serialized (updated).
Please note that the following topics will be covered sequentially.

<Upcoming Update List>

  • Entity fetching

  • Entity Relationships (FetchType.EAGER, FetchType.LAZY, LazyInitializationException, JOIN FETCH, Blaze Persistence MULTISET)

  • Stream processing

  • Query Plan Cache

Practice Environment

  • Operating System: Windows, macOS, and Linux are all supported

  • Essential Tools: JDK 17 or higher, IntelliJ IDEA or Eclipse IDE

  • Build Tools: Maven, Gradle

  • Recommended Specifications: 8GB or more of RAM and sufficient disk space

Prerequisites and Important Notes

  • Basic knowledge of Java and the Spring Framework

  • Experience using Spring Data JPA (JpaRepository, @Entity)

  • Basic knowledge of relational databases (RDB) and SQL

  • It will be even more effective if you have experience with Spring-based development in a professional setting.

Learning Materials

  • Lecture slide PDF files are provided.

  • Practice code will be provided through the GitHub repository.

  • There is a quiz at the end of each section to review the lecture content.


🔗 Relationship with existing JPA courses

  • Taking other JPA performance courses is not required.

  • If you have already taken it, this course is not a replacement but a complementary one that will help you understand the advanced content more deeply.


  • This is an advanced course that goes beyond basic optimizations like fetch joins and batch_fetch_size.


Frequently Asked Questions

Q. I already know about fetch joins and batch_fetch_size; do I still need this course?

Yes, this course starts exactly from that point. This course covers the next level: Write and DB layer optimization.

Q. How is this different from the existing "High-Performance JPA & Hibernate" course?

The previous course EntityManager/Session directly uses APIs and covers the internal workings of the Hibernate engine.
This course solves performance problems actually encountered in a JpaRepository and @Transactional based Spring Data JPA environment.
Even for the same topic of "Batching," the previous course covers "how JDBC Batch works," while this course covers "why batching doesn't work even when using saveAll() in Spring Data."

Q. How much JPA/Hibernate knowledge is required?

Experience in implementing CRUD with Spring Data JPA is sufficient.
If you have used JpaRepository, @Entity, and @Transactional, you will be able to follow all the content. If you have taken the previous course (High-Performance JPA & Hibernate), you can gain a deeper understanding, but it is not mandatory.

Q. Which database is used?

We provide comparative benchmarks for four databases: MySQL, PostgreSQL, Oracle, and SQL Server.
We also cover how to test in actual production database environments rather than just H2.

Recommended for
these people

Who is this course right for?

  • Those who need the next level of performance optimization after taking the existing JPA performance course

  • Those who have applied fetch joins and batch_fetch_size but are unsure of what to do next.

  • Those who have experienced unexpected queries being sent every time save() is called but couldn't find the cause.

  • Those who have experience with JPA performance tuning but have never delved down to the DB layer.

  • Those who handle large-scale data in practice and need to optimize not only query performance but also write performance.

Need to know before starting?

  • Experience using Spring Data JPA

  • Basic Spring Framework / Spring Boot knowledge

  • Basic knowledge of relational databases (RDB) and SQL

Hello
This is Vlad Mihalcea

1,415

Learners

77

Reviews

4.5

Rating

3

Courses

My name is Vlad Mihalcea, and I’m a Java Champion. I wrote the High-Performance Java Persistence book, which became one of the best-selling Java books on Amazon.

I'm currently developing the amazing Hypersistence Optimizer, and in my free time, I develop various open-source projects (e.g., Hypersistence Utils and FlexyPool) and answer questions on StackOverflow.

I am a Java Champion and a major contributor to the Hibernate ORM project. I created the Hypersistence Optimizer tool, which scans application configurations and mappings to identify the changes needed to speed up the data access layer.

Earned gold badges on StackOverflow by answering thousands of questions related to Hibernate, Java, and JPA tags.

When he finds something interesting, he enjoys sharing it on his personal blog. He believes in open-source software and thinks every developer should contribute in some way.

If he cannot find the right tool, he even starts new open-source projects such as Hypersistence Utils or FlexyPool.

More

Curriculum

All

41 lectures ∙ (6hr 17min)

Course Materials:

Lecture resources
Published: 
Last updated: 

Reviews

All

2 reviews

5.0

2 reviews

  • shyoon135530님의 프로필 이미지
    shyoon135530

    Reviews 1

    Average Rating 5.0

    5

    31% enrolled

    • coiio님의 프로필 이미지
      coiio

      Reviews 6

      Average Rating 5.0

      5

      35% enrolled

      Similar courses

      Explore other courses in the same field!

      $216.70