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

Introduction In this article, I’m going to explain how the Hibernate JoinFormula annotation works and how you can use it to map the latest child of a parent entity. As previously explained, the @JoinFormula is a very awesome annotation which allows you to customize the way you join entities beyond JPA @JoinColumn capabilities.

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.