High-Performance Java Persistence Newsletter, Issue 6
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 N+1 query issue is usually associated with ORM frameworks, but, in reality, this problem can happen with any data access framework. This article explains what the N+1 query issue is and how you can prevent it when using JPA and Hibernate.
If you’re using PostgreSQL, then you should definitely read this performance tuning article. You will learn how to find and generate the execution plan automatically for slow queries or find missing indexes.
The JPA SqlResultSetMapping
allows you to customize the result set of a given JPQL or native SQL query. This article explains in great detail how the JPA SqlResultSetMapping
works, as well as when you should use the associated EntityResult
, ConstructorResult
, and ColumnResult
result set transformers.
When dealing with database performance issues, it’s very important to know how to read database statistics. If you’re using MySQL, you can query the mysql.innodb_table_stats
and mysql.innodb_index_stats
virtual tables and find if a table or index statistics are outdated. For more details about this topic, check out read this article by Percona.
In this article, Lukas Eder explains how the DISTINCT keyword works in SQL and why you shouldn’t treat it as a function.
Project releases
Hibernate ORM 5.4.13 has been released, and I’m very excited about this version since there are several improvements, which I also contributed, like HHH-13103, HHH-13853, and HHH-13872.
I released the 2.9.7 version of the Hibernate Types project, which fixes an issue related to JSON objects that triggered a redundant UPDATE
statement when the Persistence Context is flushed. Also, array Hibernate Types now allow you to provide the underlying element type, which is sometimes needed when using the Hibernate addScalar
method for native SQL queries.

Get in touch with my latest articles!
StackOverflow Answers
The following StackOverflow answers have been trending over the past two weeks:
- What is the N+1 selects problem in Object-Relational Mapping?
- Can you have multiple transactions within one Hibernate Session?
- How to map the result set of a JPA NativeQuery to a POJO using
SqlResultSetMapping
- How does JPA orphanRemoval=true differ from the ON DELETE CASCADE DML clause
- How do synchronized static methods work in Java, and can I use it for loading Hibernate entities?
- How to use Space in column name with JPA and Hibernate