High-Performance Java Persistence Newsletter, Issue 27

Imagine having a tool that can automatically detect JPA and Hibernate performance issues. Hypersistence Optimizer is that tool!


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.


The pick of this edition is this article which shows you how MySQL stores data/time information in TIMESTAMP and DATETIME columns and how you can handle time zone information.

On the 23rd of May, Hibernate turned 20. To celebrate this anniversary, I wrote this article, in which I’m sharing my Hibernate journey.

If you’re using SQL Server, then you should learn how Foreign Key locking works, as it can impact concurrency if you include all the table columns during an UPDATE, which is how the default Hibernate UPDATE works. For more details about this topic and why you should use @DynamicUpdate with SQL Server, then check out this article.

Speaking of @DynamicUpdate, if you are using JSON columns, then you should also set the entity to use a dynamic UPDATE statement, as otherwise, the JSON column will be sent to the database on every property change, even if the JSON column hasn’t been modified. For more details, check out this article.

PostgreSQL 14 will add a new JSON path expression that will allow you to better locate nested attributes. For more details, check out this article.

Using a RANDOM function in the ORDER BY clause allows you to shuffle results. However, as explained in this article, the performance might not be great if the table is fairly large. So, if you’re using PostgreSQL, this article explains how you can emulate this feature using a spatial column that can have an associated spgist index.

If you’re Spring Data JPA, then JPA Entity Graphs can be useful with @Query methods. For more details about how JPA Entity Graphs work, you can read this article.

SQL workshop recording

In my previous online workshop, I talked about the best way to store JSON data and how you can query it efficiently when using Oracle, SQL Server, PostgreSQL, and MySQL.

The workshop was recorded, and I’m editing the videos. So far, I managed to edit around 40 minutes of video lessons, and many more will be coming in the upcoming days.

Therefore, if you’re interested in the following topics:

  • When to use JSON with a Relational Database System
  • Oracle JSON column types (VARCHAR vs. LOB), JSON_EXISTS, JSON_VALUE, JSON_QUERY, JSON_MERGEPATCH, JSON_TABLE, and Oracle JSON data indexing
  • PostgreSQL JSON and JSONB types, JSON path expressions, JSON operators, JSON functions, and PostgreSQL JSON data indexing
  • MySQL JSON type, JSON path expressions, JSON operators, JSON functions, and MySQL JSON data indexing

Then, you should definitely join the SQL online workshop and watch the video lessons.

Best Tweets

Here are the best tweets I posted since the last newsletter:

Project Releases

Hibernate 5.5.0 has been released, adding support for Jakarta JPA 2.2 and 3.0.

If you are using Hibernate 5.4, then you might want to upgrade to the 5.4.32 version, which fixes several issues and add new improvements.

The 2.11 version of the Hibernate Types project has been released, and it provides a new JsonType that works with PostgreSQL, MySQL, Oracle, SQL Server, and H2 without having to do any change in your mapping. With this improvement, you can address the portability issues of using DB-specific JSON columns.

If you’re using PostgreSQL, then you might be interested in the 13.3 release, which provides several bug fixes.

And, if you’re using MySQL, then check out the 8.0.25 release.

If you like this newsletter,

you are going to love the next episodes!

StackOverflow Answers

The following StackOverflow answers have been trending over the past two weeks:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.