'Spring.jpa.open-in-view gives exception

When starting the server I always got a warning :

spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering

So now I set in my application.properties file this: spring.jpa.open-in-view=false

But now when I call a page I always get an org.hibernate.LazyInitializationException . Whenever there is a lazy load in my Entity this gives me an error.

org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: de.domain.entitiy.GroupEntity.types, could not initialize proxy - no Session

So first of all why is there a warning in the beginning. Why to set spring.jpa.open-in-view=false



Solution 1:[1]

Set in my application.properties file this: spring.jpa.open-in-view=true

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 diegoizac