Overriding FetchType.EAGER with fetchgraph

Introduction In this article, we are going to see how you can override the FetchType.EAGER strategy using the fetchgraph query hint. While this feature has been available in the JPA specification since version 2.1, Hibernate has only supported this feature since version 5.5.

High-Performance Java Persistence Newsletter, Issue 62

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

The best way to use the JPA OneToOne optional attribute

Introduction In this article, we are going to see what is the best way we can use OneToOne optional attribute so that we can avoid N+1 query issues.

High-Performance Java Persistence Newsletter, Issue 61

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

High-Performance Java Persistence Newsletter, Issue 60

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

How to use Java Records with Spring Data JPA

Introduction In this article, we are going to see how we can use Java Records with Spring Data JPA Repositories. As I already explained, Java Records cannot be used as JPA entities since the Records are immutable, and JPA requires the entity class to have a default constructor and be modifiable, as that’s how the entity properties are populated when the entity is being fetched from the database. For this reason, this article will show you how to combine Java Records and JPA entities so that you get the best out of… Read More

High-Performance Java Persistence Newsletter, Issue 59

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

Fetching recursive associations with JPA and Hibernate

Introduction In this article, we are going to see how to fetch recursive associations when using JPA and Hibernate. Recursive table relationships are built using self-referencing Foreign Key columns so that a record in a table can reference another record in the very same table, therefore allowing us to represent hierarchical structures using the relational model.

High-Performance Java Persistence Newsletter, Issue 58

Introduction Welcome to a new issue of the High-Performance Java Persistence Newsletter in which we share articles, videos, workshops, and StackOverflow answers that are very relevant to any developer who interacts with a database system using Java.

The best way to map multiple entities on the same table

Introduction In this article, we are going to see what is the best way to map multiple entities on the same table. There are several advantages to mapping multiple entities on the same database table: To avoid loading large columns (e.g., JSON) To avoid N+1 query issues for bidirectional @OneToOne associations Before we start investigating the best way to map multiple entities on the same table, if you wonder why you even need to use one-to-one table relationships, then check out this article first.