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

How to fix “wrong column type encountered” schema-validation errors with JPA and Hibernate

Introduction

Mapping entities to database tables is usually a very straightforward process. However, if your mappings are rather unusual, you might bump into some rare issues like this one I found on the Hibernate forum.

In this article, I’m going to explain the mapping between Java objects to JDBC and database column types, and how you can fix the issue described in the aforementioned Hibernate question.

Continue reading “How to fix “wrong column type encountered” schema-validation errors with JPA and Hibernate”

How to map the latest child of a parent entity using Hibernate @JoinFormula

Introduction

Today, I stumbled upon a StackOverflow answer that I gave some time ago and realized that it deserves a post of its own.

As previously explained, the @JoinFormula is a very awesome annotation which allows you to customize the way you join entities beyond JPA @JoinColumn capabilities.

Continue reading “How to map the latest child of a parent entity using Hibernate @JoinFormula”