Persist LocalDateTime, ZonedDateTime & Co with Hibernate

Persist LocalDateTime, ZonedDateTime & Co with Hibernate

The Date and Time API, introduced in Java 8, finally replaced the old java.util.Date. It’s much easier to use and finally offers separate classes representing date, date with time, and only time information. That not only improves your business code but also makes it easier to use them as entity attributes. At least if you’re…

FetchType: Lazy/Eager loading for Hibernate & JPA
|

FetchType: Lazy/Eager loading for Hibernate & JPA

Choosing the right FetchType is one of the most important decisions when defining your entity mapping. It specifies when your JPA implementation, e.g., Hibernate, fetches associated entities from the database. You can choose between EAGER and LAZY loading. The first one fetches an association immediately, and the other only when you use it. I explain…

Hibernate Performance Tuning – 2024 Edition
| |

Hibernate Performance Tuning – 2024 Edition

Based on most discussions online and at conferences, there seem to be 2 kinds of projects that use Hibernate for their persistence layer: So, what’s the difference between these projects? Are the projects in the 2nd group more complex or have higher performance requirements? No, based on my consulting projects, that’s not the case. On…

Inheritance Strategies with JPA and Hibernate – The Complete Guide
|

Inheritance Strategies with JPA and Hibernate – The Complete Guide

Inheritance is one of the key concepts in Java. So, it’s no surprise that most developers want to use it in their domain model. Unfortunately, the relational table model doesn’t know this concept. So, Hibernate, or any other JPA implementation, has to apply a mapping strategy to map your inheritance hierarchy to one or more…