How to fetch multiple to-many relationships with jOOQ MULTISET

Introduction In this article, we are going to see how we can fetch multiple to-many relationships with jOOQ MULTISET so that we avoid bumping into an unintentional Cartesian Product. The approach taken by jOOQ is truly revolutionary since it offers a solution that allows you to fetch multiple to-many relationships using a single type-safe query.

A beginner’s guide to database table relationships

Introduction In a relational database, a relationship is formed by correlating rows belonging to different tables. A table relationship is established when a child table defines a Foreign Key column that references the Primary Key column of its parent table. Every database table relationship is, therefore, built on top of Foreign Key columns, and there can be three table relationship types: one-to-many is the most common relationship, and it associates a row from a parent table to multiple rows in a child table. one-to-one requires the child table Primary Key to be… Read More

The best way to map a JPA and Hibernate many-to-many association with extra columns

Introduction For a simple many-to-many database relationship, you can use the @ManyToMany JPA annotation and, therefore, hide the join table. However, sometimes you need more than the two Foreign Key columns in the join table, and, for this purpose, you need to replace the @ManyToMany association with two bidirectional @OneToMany associations. Unlike unidirectional @OneToMany, the bidirectional relationship is the best way to map a one-to-many database relationship that requires a collection of Child elements on the parent side In this article, we are going to see how you can map a many-to-many… Read More

Best way to map the JPA and Hibernate ManyToMany relationship

Introduction In this article, I’m going to show you the best way to map a ManyToMany association when using JPA and Hibernate. As simple as JPA annotations might be, it’s not always obvious how efficient they are behind the scenes.

A beginner’s guide to JPA and Hibernate Cascade Types

Introduction In this article, we are going to learn how the JPA and Hibernate Cascade Types work. JPA translates entity state transitions to database DML statements. Because it’s common to operate on entity graphs, JPA allows us to propagate entity state changes from Parents to Child entities. This behavior is configured through the CascadeType mappings.