Dev.to
7/11/2026

The original title is: "Open Session in View Is Convenient — Until It Hides Your Lazy Loading Problem"
Original: Open Session in View Is Convenient — Until It Hides Your Lazy Loading Problem
Short summary
This article explains why Spring Boot's Open Session in View pattern is dangerous despite being enabled by default. It keeps the JPA persistence context open during view rendering, silently allowing database queries outside the service layer. This hides lazy loading problems, causes unexpected SQL after service methods return, and makes performance issues hard to diagnose.
- •Open Session in View silently allows DB queries during DTO mapping and JSON serialization
- •Service method timing looks fast while the overall request is slow due to hidden queries
- •Disabling it surfaces LazyInitializationException, which is annoying but useful for catching architectural issues
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


