Spring boot @Transactional

我们两清 提交于 2019-12-05 20:35:15

I'm just guessing but I assume what you're trying to ask here is why you're able to load lazy collections on your entities inside your controller?

Spring Boot configures the following application property spring.jpa.open-in-view with a default value of "true". Basically this opens a session for the entire request allowing you to do things like the above outside of a @Transactional.

Adding this to your application.properties will turn it off:

spring.jpa.open-in-view=false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!