The best way to map a @NaturalId business key with JPA and Hibernate

Introduction In this article, you are going to learn what the Hibernate natural id is and how you can use it to fetch entities based on a business key. As I explained in this free chapter of my book, Hibernate offers many benefits over standard JPA. One such example is the @NaturalId mapping. In this article, you are going to see what is the best way to map a natural business key when using Hibernate.

How does Hibernate handle JPA Criteria API literals

Introduction The JPA specification is like a Java interface, However, when it comes to performance, implementation details matter a lot. That’s why, even if you use the JPA standard, you still need to know how the underlying provider implements the standard specification. For instance, if we take this tweet from Gareth Western: We can clearly see that there is an issue in the way literals might be handled by Hibernate when executing a Criteria API query. Therefore, in this article, we are going to see how literals are handled by Hibernate and… Read More

9 High-Performance Tips when using MySQL with JPA and Hibernate

Introduction Although there is an SQL Standard, every relational database is ultimately unique, and you need to adjust your data access layer so that you get the most out of the relational database in use. In this article, we are going to see what you can do to boost up performance when using MySQL with JPA and Hibernate.

How to JOIN unrelated entities with JPA and Hibernate

Introduction Answering questions on the Hibernate forum is a neverending source of inspiration. The following question is about joining unrelated entities using entity queries, and this post is going to explain how you can do it when using JPA and Hibernate.

How to solve the PostgreSQL :: cast operator issue with JPA and Hibernate

Introduction While answering questions on the Hibernate forum, I stumbled on the following question regarding the PostgreSQL :: cast operation used in a JPA and Hibernate entity query. Since it’s a very interesting use case, I decided to turn the answer into a dedicated blog post.