How to cache non-existing entity fetch results with JPA and Hibernate

Introduction Sergey Chupov asked me a very good question on Twitter: https://twitter.com/scadgek/status/946838214744203269 In this article, I’m going to show you how to cache null results when using JPA and Hibernate.