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 @JoinForuma 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”

Advertisements

How to customize an entity association JOIN ON clause with Hibernate @JoinFormula

Introduction

As I explained in this previous article, you can map calculated properties using Hibernate @Formula, and the value is generated at query time.

In this post, you’ll see how you can use a custom SQL fragment to customize the JOIN relationship between two entities, or an entity and a collection of embeddable types.

Continue reading “How to customize an entity association JOIN ON clause with Hibernate @JoinFormula”