The best way to replace the deprecated GenericGenerator

Introduction In this article, I’m going to show you the best way to replace the deprecated @GenericGenerator when upgrading your application to Hibernate 7.

The best way to clean up test data with Spring and Hibernate

Introduction In this article, I’m going to show you the best way to clean up test data when using Spring and Hibernate. While it’s very common to use the @DataJpaTest annotation when implementing integration tests, in this blog post, you will see why you are better off avoiding using this annotation.

How to map the Oracle TIMESTAMP WITH TIME ZONE with JPA

Introduction In this article, I’m going to explain how to map the Oracle TIMESTAMP WITH TIME ZONE with JPA and Hibernate. While the DATE and TIMESTAMP column types are suitable for mapping the LocalDateTime, the TIMESTAMP WITH TIME ZONE column type allows us to map both the ZonedDateTime and OffsetDateTime.

Avoid using Set for bidirectional JPA OneToMany collections

Introduction In this article, we are going to see why there is no benefit in using the Set collection type when mapping a bidirectional JPA OneToMany association. While the @OneToMany annotation can be used to map both unidirectional and bidirectional associations, as I explained this article, you should avoid the unidirectional mapping since it can lead to very inefficient SQL statements.

JTA Transaction Type

Introduction In this article, we are going to analyze how the JTA transaction type works. Since this is the default transaction type when using Jakarta EE or Java EE applications, it’s very important to understand how JTA transactions work, especially since Spring Boot or Spring applications use RESOURCE_LOCAL transactions instead.

RESOURCE_LOCAL JPA Transaction Type

Introduction In this article, we are going to analyze how the RESOURCE_LOCAL JPA transaction type works. Since this is the default transaction type when using Spring Boot or Spring Data JPA, it’s very important to understand how transactions are managed when using the RESOURCE_LOCAL mode.

Embeddable Inheritance with JPA and Hibernate

Introduction In this article, we are going to see how we can map embeddable inheritance when using JPA and Hibernate. The feature described in this article is available since version 6.6 of Hibernate ORM, so if you haven’t yet upgraded, then you have one more reason to consider it.

Custom Spring Boot Actuator Endpoint

Introduction In this article, we are going to see how we can create a custom Spring Boot Actuator endpoint in order to export our own metrics and events. Spring Boot Actuator is a Spring Boot module that provides support for tracing and monitoring. And, while by default, we get various health checks and metrics, we are not limited to the default implementation.

How to integrate Jakarta Data with Spring and Hibernate

Introduction In this article, we are going to see how we can integrate Jakarta Data with Spring and Hibernate. Jakarta Data is a new Jakarta EE specification that provides a common API for building data Repositories and data access objects. If you are familiar with Spring Data JPA, you will see that Jakarta Data is very much inspired by this Spring API.

Hibernate SoftDelete annotation

Introduction In this article, we are going to see how we can use the Hibernate SoftDelete annotation to activate soft deleting for JPA entities. While, as I explained in this article, you can manually implement the soft delete mechanism using the @SQLDelete, @Loader and @Where annotations, it’s definitely much easier to just use the native Hibernate mechanism introduced in Hibernate 6.4 , which you can enable via the @SoftDelete annotation.