Open Session in View
Get introduced to Open Session in View.
We'll cover the following...
We'll cover the following...
What is OSIV?
If we observe the logging output of the Spring Boot application, we will see this warning:
By default, Spring Boot has Open Session In View (OSIV) enabled. However, this is considered to be an antipattern by many.
Why is OSIV an anti-pattern?
To answer that question, let’s first explain what Open Session In View does. Put simply:
The Session is what JPA/Hibernate needs to make the database work.
When a controller calls a service, a transaction is started and spans all database calls that the service does (via a repository). The transaction/session is closed when the service returns the deserialized objects to the controller. As a performance optimization, some references of a returned entity are lazy-loaded. ...