High-Performance Java Persistence Newsletter, Issue 15
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 written by Franck Pachot, in which he debunks the myth that SQL JOINs don’t scale.
If you’re using JPA, and you want to customize the way an entity attribute is persisted and fetched, then you could use an AttributeConverter. This article explains how the JPA AttributeConverter works, and how you can use it to persist a
java.time.MonthDay entity attribute to a
DATE column type.
The Hibernate bytecode enhancement mechanism offers an alternative to the default dirty checking strategy. By default, the bytecode enhancement dirty tracking mechanism intercepts the entity setter method calls to record which entities have been modified. If you want to intercept changes that happen via
@Transient methods, then you could use the enhanced enhancement mode. For more details about the
enableExtendedEnhancement option, check out this article.
While Hibernate makes it very easy to enable batching for INSERT, UPDATE, and DELETE statements, if you want to modify multiple records that match some filtering criteria, then bulk processing can be more efficient than batching. For more details about this topic, check out this article.
If you’re wondering how SQL-based databases (RDBMS and NewSQL) differ from NoSQL database systems, then this article from IBM is surely going to help you get a better understanding of this topic.
I added a new YouTube video in which I explain how the JDBC Statement fetch size works on Oracle, SQL Server, PostgreSQL, MySQL. This video episode is part of my High-Performance Java Persistence video course, so if you like the video, you are going to love the video course even more.
Hibernate ORM released the 5.4.20 version, so if you’re using the 5.4 branch, you might want to upgrade to the latest version and benefit from the bug fixes that were added to this version.
There are many social media platforms, but for me, Twitter is the one I like best. Here are the best tweets I posted since the last newsletter:
Why write an SQL query when you can fetch the entire database table with a findAll method call and process the result with the Java Stream API in order to find the single record you are interested in? pic.twitter.com/a49HdhzQCj— Vlad Mihalcea (@vlad_mihalcea) August 10, 2020
Donald Knuth's "premature optimization is the root of all evil" is about micro-optimizations.— Vlad Mihalcea (@vlad_mihalcea) August 13, 2020
You still need to design your application so that it reads and writes data efficiently. That's not premature optimization. That's software engineering.
That day will never come:— Vlad Mihalcea (@vlad_mihalcea) August 7, 2020
- One day, I'll add some unit tests for this.
- I'll write the documentation later when I have some time.
- I'll start blogging or write a book after I finish this sprint or release.
Unless you start doing it now, you'll keep on lying to yourself.
Don't avoid framework or database-specific features in the name of portability!— Vlad Mihalcea (@vlad_mihalcea) August 5, 2020
How many times did you have to switch JPA providers? Most likely, never!
Switching database systems in an enterprise project is not common either. In 15 years, only once we had to migrate the DB.
I value soft skills better than technical skills because teaching tech is very easy. On the other hand, acquiring good habits and shaping your personality requires a lot of time and effort.— Vlad Mihalcea (@vlad_mihalcea) August 12, 2020
Get in touch with my latest articles!
The following StackOverflow answers have been trending over the past two weeks:
- How to encrypt a column in Postgres using Hibernate @ColumnTransformer
- How to get a random ordering for the SQL result set
- Can you do bulk delete in one transaction using JPA and Hibernate?
- What is the best way to bulk delete rows in JPA while also cascading the delete to child records
- How to execute a JPA Bulk Update statement which takes a List as a parameter value
- PostgreSQL LIMIT with OFFSET is not working beyond 100000