Persistence magic with SB and Hibernate
|

Managing Detached Entities with Spring Boot and Hibernate

Dealing with detached objects is a common issue when working with Spring Boot and Hibernate. When you load an entity from the database, make some changes, and then save it, sometimes the updated entity becomes detached from the Hibernate Session, which can lead to issues. This post shows how to effectively manage detached entities and avoid data inconsistencies.

Featured image
|

Optimizing Eager Fetch with Spring Data and EntityGraph Annotation

The LazyInitializationException is a common occurrence when using Hibernate. It typically happens when you access a lazy-loaded association outside of the persistence context in which it was loaded. I will show you how to prevent this exception without compromising the performance of your application. Through the lens of Spring Data, I will explain how to resolve this challenge with a handy annotation: @EntityGraph. Implementing this strategy allows you to optimize both for efficiency and effectiveness, avoiding one of the common pitfalls in Hibernate.