Recently I got the chance to work through Vlad Mihalcea’s High-Performance Java Persistence Video Course (Version: Mach 2) and in this blog post, I’ll give you a review about this excellent course on tuning your data access layer based on Hibernate and JPA.
When starting my career as a Java software developer I had the most headaches while fiddling with the relational data access of the application. Together with my project members/co-workers we were copy & pasting code snippets from Stack Overflow when running into a JPA/Hibernate issue in the early days. Besides the Object-relational impedance mismatch, we had to figure out how to use Hibernate as efficient as possible as most of the performance issues of enterprise applications come from the data access layer.
After working through some basic Hibernate tutorials on YouTube and Udemy I’ve instantly bought Vlad Mihalcea’s High-Performance Java Persistence book as he was in many cases my first address when running into a performance issue. This book alone is totally worth every cent as you’ll get a full understanding of how the relational data access with JPA and Hibernate works plus tips for tuning your application. Today I’m still using his book as a reference guide and it should be part of the bookshelf of every serious Java developer.
As I personally learn the most from video tutorials I took the time to work through his High-Performance Java Persistence Video Course (Version: Mach 2). I wanted to get a deeper understanding and improve my Hibernate performance tuning skills and as Vlad is also highly contributing to Hibernate, I think there can be no better coach for a framework or technology than one of the main committers. He knows the implementation behind and can advise you how to use the framework correctly.
The whole course is structured in nine video course modules with 35 videos and about 337 minutes in total. You’ll learn about performance tuning for the following topics:
- Data types
- Entity identifiers
- Entity Relationships
- Persistent Context and Flushing
In most of the videos, Vlad is explaining the performance pitfall with a short slide-deck and a sample entity setup. After the introduction to the problem, he presents the possible solution while switching to unit tests to show the impact with a running example.
As he uploads the full source code for the course on GitHub, you can clone and run the tests locacally. He maintains his repository for every new major Hibernate release so that you won’t get outdated information.
In addition, Vlad isn’t presenting only one solution which might not be applicable for every use case. He always evaluates the pros and cons of his solutions. What I also like the most is that he’s measuring the impact of a suggested solution and is showing the result of his measurements with the raw numbers:
As not every implementation works for every database vendor, he’s always referring to the solution or workaround for Oracle, PostgreSQL, MySQL, and MS-SQL.
I personally got the most of the section about the write-behind concept of the
EntityManager and how Hibernate’s AUTO flush mode differs from the JPA spec as their understanding is important to know how and when Hibernate executes the SQL statements. You’ll also get an excellent explanation for modeling the entity relationships uni- or bidirectional with
@OneToOne/@ManyToOne/@ManyToMany ... and how you can optimize them.
In summary, I can totally recommend this course as Vlad has great teaching skills and perfectly mixes theoretical input with running code examples. To get the most of the course, you should be familiar with the JPA spec and Hibernate as a reference implementation.
So if you are a Jakarta EE/Java EE/Spring developer, you should definitely have a look into the course or start with his book. The information you get is of high-quality and definitely worth the money. Just compare it to the worth of your time you lose or have already lost on Stack Overflow while trying to apply random code snippets to improve your performance.
Have fun optimizing your application’s performance,