How to get the SQL query from JPQL or JPA Criteria

Introduction In this article, I’m going to show you how you can get the auto-generated SQL query from a JPQL or JPA Criteria API entity query.

High-Performance Java Persistence Newsletter, Issue 10

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 from Java.

How to generate JPA entity identifier values using a database sequence

Introduction In this article, I’m going to show you how you can generate entity identifier values using a database sequence when using JPA and Hibernate. Using a database sequence is the most efficient Hibernate identifier generation strategy, as it allows you to take advantage of the automatic JDBC batching mechanism.

How to fetch a one-to-many DTO projection with JPA and Hibernate

Introduction In this article, I’m going to show you how you can fetch a one-to-many relationship as a DTO projection when using JPA and Hibernate. While entities make it very easy to fetch additional relationships, when it comes to DTO projections, you need to use a ResultTransformer to achieve this goal.

High-Performance Java Persistence Newsletter, Issue 9

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 from Java.

ManyToOne JPA and Hibernate association best practices

Introduction In this article, I’m going to show you what is the best way to map a ManyToOne association when using JPA and Hibernate. Since the @ManyToOne association is the most common relationship, knowing how to map it properly will have a significant impact on application performance.

How to map Date and Timestamp with JPA and Hibernate

Introduction In this article, I’m going to show you what is the best way to map date and timestamp column types when using JPA and Hibernate. While there are many options to map date and timestamp columns on the Java side, as you will soon see, not all of them are suitable.

High-Performance Java Persistence Newsletter, Issue 8

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 from Java.

The best way to use Java Records with JPA and Hibernate

Introduction In this article, I’m going to show you how you can use Java Records with JPA and Hibernate. Added since version 14 as a preview feature, Java Records allow us to create compact DTOs (Data Transfer Objects) or Value Objects.

JPA Criteria Metamodel Generation and Usage Guide

Introduction In this article, I’m going to show you how to generate the JPA Metamodel using Hibernate, and how you can use it to write typesafe Criteria API queries.