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.

Continue reading “How to customize an entity association JOIN ON clause with Hibernate @JoinFormula”

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.

Continue reading “One year as a Developer Advocate”

How does MySQL result set streaming perform vs fetching the whole JDBC ResultSet at once

Introduction

I read a very interesting article by KreŇ°imir Nesek regarding MySQL result set streaming when it comes to reducing memory usage.

Mark Paluch, from Spring Data, asked if we could turn the MySQL result set streaming by default whenever we are using Query#stream or Query#scroll.

That being said, the HHH-11260 issue was created, and I started working on it. During Peer Review, Steve Ebersole (Hibernate ORM team leader) and Sanne Grinovero (Hibernate Search Team Leader) expressed their concerns regarding making such a change.

First of all, the MySQL result set streaming has the following caveats:

  • the ResultSet must be traversed fully before issuing any other SQL statement
  • the statement is not closed if there are still records to be read in the associated ResultSet
  • the locks associated with the underlying SQL statement that is being streamed are released when the transaction is ended (either commit or rollback).

Continue reading “How does MySQL result set streaming perform vs fetching the whole JDBC ResultSet at once”

How to map calculated properties with JPA and Hibernate @Formula annotation

Introduction

As I explained in this StackOverflow question, mapping calculated properties is very easy with JPA and Hibernate.

In this post, I’m going to demonstrate how you can derive some entity property based on one or multiple persistent entity attributes.

Continue reading “How to map calculated properties with JPA and Hibernate @Formula annotation”