High-Performance Java Persistence Newsletter, Issue 52
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!
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 provides a very thorough explanation of how queries are executed and how you should read the execution plan when using SQL Server.
One of the greatest challenges when fetching multiple one-to-many and many-to-many relations is to avoid the implicit Cartesian Product. Using the jOOQ MULTISET operator helps you deal with this issue in a type-safe manner that’s also very efficient. If you are interested in this feature, check out this article.
It’s very common to bump into database comparison articles, but, in reality, most of them are rather biased to the writer’s preference or outdated experience. If you want to read a very balanced comparison of MySQL and PostgreSQL, then check out this article.
Database systems provide three types of table relationships: one-to-many, one-to-one, and many-to-many. If you’re curious why you’d even need a one-to-one relationship, then check out this article, in which I provide a thorough list of advantages of using this table relationship.
If you’re using PostgreSQL and thinking of using table partitioning, then check out this article, which explains how you may end up in a LockManager wait situation.
If you’re using JPA and Hibernate, then you may be already familiar with the
hbm2ddl tool. Since this tool provides a
validate option, it’s important to know what’s the best way to take advantage of this strategy. To help you with this task, I wrote this article that explains how you can run this schema validation without having to pay this overhead on every test execution.
Spring offers a great variety of querying strategies, like query methods,
@Query annotation, or
Specification. A lesser-known feature is the Query By Example (QBE). If you want to see how this feature works and what are the downsides of using it, then check out this article.
Here are the best tweets I posted since the last newsletter:
💥 When fetching multiple one-to-many or many-to-many relations, your SQL can generate an unintentional Cartesian Product, and that's bad!— Vlad Mihalcea (@vlad_mihalcea) June 26, 2023
👇 Want to learn what the best way to deal with this issue? Check out this article.https://t.co/P2MnxJPt1s pic.twitter.com/mniwzXi9gH
There were also fours releases for the Hypersistence Utils project:
Especially if you are using Hibernate 6.2 and 6.1, you should definitely upgrade to using the 3.5.1 version of this library.
Hibernate ORM released two versions for the 6.2 branch:
Get in touch with my latest articles!
The following StackOverflow answers have been trending since the last newsletter episode:
- MySQL Repeatable Read isolation level and Lost Update phenomena
- How to change Hibernate GenerationType identifier depending on the underlying database
- How do I obtain a Query Execution Plan in SQL Server?
- Retry OpmisticLockException with Hypersistence Utils library does not work
- ORDER BY performance when executing a query in Oracle