High-Performance Java Persistence Newsletter, Issue 56
Imagine having a tool that can automatically detect JPA and Hibernate performance issues. Wouldn’t that be just awesome?
Well, Hypersistence Optimizer is that tool! And it works with Spring Boot, Spring Framework, Jakarta EE, Java EE, Quarkus, or Play Framework.
So, enjoy spending your time on the things you love rather than fixing performance issues in your production system on a Saturday night!
Introduction
Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.
Articles
The pick of this edition is this article about MySQL 8.2 automatic read and write routing. Until MySQL 8.2 is released, if you’re using Spring, then you can check this strategy instead.
Speaking of Spring, if you’re using Stream
query results, then check out this article that explains how to set the Statement
fetch size when streaming the query result set.
When using JPA and Hibernate, you can use the CascadeType.REMOVE
mechanism to make sure that the child entities are removed prior to deleting a parent entity. However, this works for bidirectional @OneToMany
or @OneToOne
associations but not for unidirectional ones. Therefore, if you have only unidirectional @OneToMany
or @OneToOne
associations and want to cascade the DELETE from parent to child entities, then check out this article.
The JPA IDENTITY
strategy prevents the automatic batch insert mechanism because the INSERT is generated right away during the persist
call, instead of being delayed until the Persistence Context is flushed. However, if you’re using MySQL and you don’t have support for database sequences, then you can use this trick to batch INSERT statements.
4-day High-Performance Java Persistence online training
Between the 20-21 and 22-23 of November, from 09:00 to 13:00 CET (Central European Time), I’m going to run a new session of my High-Performance Java Persistence online training.
During these 4 days, we are going to cover the entire agenda of the High-Performance Java Persistence training.
Here’s a list of things that we are going to dive into:
- How to test your data access layer
- Logging best practices
- Connection management and monitoring
- Mapping best practices (entities, associations, inheritance)
- Persistence Context and entity state transitions
- Batch processing
- Statement caching
- Fetching best practices
- Caching best practices
- Transactions and Concurrency Control
If you are using JPA and Hibernate, then you should definitely join this training, as it will help you get the most out of your relational database system.
Best Tweets
Here are the best tweets I posted since the last newsletter:
Senior developers don't mind writing boring code with boring technologies
— Vlad Mihalcea (@vlad_mihalcea) October 14, 2023
Frameworks come and go.
— Vlad Mihalcea (@vlad_mihalcea) October 26, 2023
Relational databases stay.
I started learning Java in 2003, and after 20 years, I still enjoy building projects with it.
— Vlad Mihalcea (@vlad_mihalcea) October 19, 2023
Learning Java has been one of the best career moves I've ever made.
Pro tip: When you find an issue, first write a test case that replicates the issue, and only afterward start fixing it.
— Vlad Mihalcea (@vlad_mihalcea) October 23, 2023
Not only does the test prove whether the fix is working, but it will also help you avoid a regression on the same issue in the future.
Code quality is a function of technical leadership
— Vlad Mihalcea (@vlad_mihalcea) October 29, 2023
Project Releases
MySQL 8.0.35 has been released, and it provides several bug fixes for the MySQL 8 version.
The 12.4.2 version of the SQL Server JDBC Driver has been released, fixing one issue related to the JVM vendor.
The Hibernate ORM project has released the first candidate release for the 6.4 version, adding native support for soft deletes, HQL array functions, as well as support for Java Flight Recorder (JFR) for the SessionEventListever
events.
The 3.6 version of Hypersistence Utils has been released with several improvements for the QueryStackTraceLogger
.

Get in touch with my latest articles!
StackOverflow Answers
The following StackOverflow answers have been trending since the last newsletter episode:
- Minimum transaction isolation level to avoid “Lost Updates”
- Registering a SQL function with JPA and Hibernate
- How to call a Stored Procedure from Hibernate having both IN and OUT parameters
- Can JPA cache query every time we execute a SELECT statement?
- Consequences of not using an
EntityManager
with Hibernate