How to map table rows to columns using SQL PIVOT or CASE expressions

Introduction While reading the wonderful SQL Antipatterns book by Bill Karwin, which is a great reference for any developer that needs to interact with a Relational Database System, I found an example where the SQL PIVOT clause would work like a charm. In this post, I’m going to explain how to transpose a ResultSet using PIVOT so that rows become columns.

Book Review – Designing Data-Intensive Applications

Introduction Exactly one year ago, I bought Designing Data-Intensive Applications by Martin Kleppmann. However, since I was busy writing High-Performance Java Persistence, it took me over a year to find the time to read Martin Kleppmann’s book. This post is a review of what this book is all about and why you should be interested in reading it. Audience If you are a backend developer, a team leader or a software architect, this book must be on your reading list. While a junior developer might find the book interesting too, you got… Read More

The performance penalty of Class.forName when parsing JPQL and Criteria queries

Introduction While reviewing this Hibernate Pull Request, I stumbled on the HHH-10746 Jira issue. After doing some research, I realized that this issue was reported multiple times in the past 10 years: HHH-1810 HHH-4959 HHH-11246 In this post, I’m going to explain why this issue was causing performance issues, and how it got fixed.

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.

One year as a Developer Advocate

Introduction Exactly one year ago today, I started working as a Developer Advocate for the Hibernate team at Red Hat. Prior to joining Red Hat, I used to work as a software architect, and I didn’t have any clue what I would have to do as a Developer Advocate. So, I learned on the way. This post is a summary of what this role is about, and what I’ve managed to accomplish.