The best way to map an Enum Type with JPA and Hibernate

Introduction

Recently, I got a very good question on Twitter, and I decided that the best way to answer it is with a new article.

In this article, we are going to see how various ways to map an Enum using JPA and Hibernate.

Continue reading “The best way to map an Enum Type with JPA and Hibernate”

Advertisements

The best way to fix the Hibernate “HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!” warning message

Introduction

If you’ve been using Hibernate long enough, then you surely must have seen this WARN log message when doing pagination while join fetching multiple entities.

HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!

In this article, I’m going to show a very elegant solution to fix this issue.

Continue reading “The best way to fix the Hibernate “HHH000104: firstResult/maxResults specified with collection fetch; applying in memory!” warning message”

How to map a composite identifier using an automatically @GeneratedValue with JPA and Hibernate

Introduction

One of my readers asked me to answer the following StackOverflow question.

While I already covered the best way to map composite identifiers with JPA and Hibernate, this use case is different because one column is automatically generated.

Continue reading “How to map a composite identifier using an automatically @GeneratedValue with JPA and Hibernate”

The best way to map a projection query to a DTO (Data Transfer Object) with JPA and Hibernate

Introduction

While answering questions on the Hibernate forum, I stumbled on the following question. What was different than previous questions on the same topic was that the original poster realized the shortcoming of the JPA constructor expression which can be addressed elegantly by Hibernate.

Because this has been a recurring theme on StackOverflow and the Hibernate forum, I decided to dedicate an article to the best way of mapping DTO projections using JPA and Hibernate.

Continue reading “The best way to map a projection query to a DTO (Data Transfer Object) with JPA and Hibernate”