Introduction I recently answered this question on the Hibernate forum, and since it’s a very good one, I decided to turn it into an article. In this post, we will describe how the N+1 query issue is generated when using the second-level Hibernate Query Cache.
Introduction Sergey Chupov asked me a very good question on Twitter: My use-case is a search by complex primary key, but the performance test still showed a degrade. I'm now using a query cache instead, which helps, but it doesn't look right to have a separate query for the search by PK. So I'm wondering if there's a better approach — Sergey Chupov (@scadgek) December 29, 2017 In this article, I’m going to show you how to cache null results when using JPA and Hibernate.
Introduction On the Hibernate forum, I noticed the following question which is about using the Hibernate Query Cache for storing DTO projections, not entities. While caching JPQL queries which select entities is rather typical, caching DTO projections is a lesser-known feature of the Hibernate second-level Query Cache.