How to order entity subclasses by their class type using JPA and Hibernate

Introduction

One of my blog readers asked me a very good question, and so I decided to turn the answer it into a blog post.

In this article, we are going to see how to order entity subclasses when executing a JPQL query with Hibernate.

Continue reading “How to order entity subclasses by their class type using JPA and Hibernate”

Advertisements

Two years as a Hibernate Developer Advocate

Introduction

Exactly two years ago today, I started working as a Developer Advocate for the Hibernate team at Red Hat.

I wrote a report a year ago to summarize my accomplishments for the Hibernate project, so it’s time to see what’s been done since last year.

Continue reading “Two years as a Hibernate Developer Advocate”

How to become a Java Champion

1515 days

That’s how much time it took me from the moment I started this blog, until I became a Java Champion.

In this article, I’m going to show you what I did so that, after 1515 days, I became the first Java Champion from Romania.

Continue reading “How to become a Java Champion”

How to map a JPA @ManyToOne relationship to a SQL query using the Hibernate @JoinFormula annotation

Introduction

Someone asked me to answer the following StackOverflow question, and, because the question is very interesting from an SQL perspective, I decided to turn the answer it into a blog post.

In this article, we are going to see how to map a JPA @ManyToOne association to the result of a SQL query using the Hibernate-specific @JoinFormula annotation.

Continue reading “How to map a JPA @ManyToOne relationship to a SQL query using the Hibernate @JoinFormula annotation”

How to audit entity modifications using the JPA @EntityListeners, @Embedded, and @Embeddable annotations

Introduction

After I wrote the article about inheriting properties from a base class entity using @MappedSuperclass, I got an avalanche of opinions, but this one from Lukas deserves a blog post:

While @MappedSuperclass has its benefit, allowing you to reuse even the @Id mapping, as well as being more lenient towards Hibernate-specific auto-generated properties like @GeneratedValue, using Embeddable types is the other JPA alternative for reusing a bunch of properties among multiple entities.

In this article, we are going to see how we can reuse several audit-related properties using @Embeddable and another awesome JPA feature, @EntityListeners.

Continue reading “How to audit entity modifications using the JPA @EntityListeners, @Embedded, and @Embeddable annotations”