Spring Boot中的spring.jpa.open-in-view = true属性是什么? [英] What is this spring.jpa.open-in-view=true property in Spring Boot?
问题描述
我在Spring Boot文档中看到了JPA配置spring.jpa.open-in-view=true
的此属性.顺便说一句,它被设置为true,所以它是默认值吗?
I saw in Spring Boot documentation this property for JPA configuration spring.jpa.open-in-view=true
. By the way, it was set as true, so is it the default value?
这到底是什么意思?对于这种行为,我没有找到任何解释.
What does it really mean? I did not find any explaining for this behaviour.
应该使用Hibernate SessionFactory
代替EntityManagerFactory
吗?如果是,如何设置为EntityManagerFactory
?
Should it be to use Hibernate SessionFactory
instead EntityManagerFactory
? If yes, how can I set to EntityManagerFactory
?
感谢任何帮助.
谢谢!
推荐答案
此属性将注册一个OpenEntityManagerInViewInterceptor
,该注册一个EntityManager
到当前线程,因此您将拥有相同的EntityManager
,直到Web请求为止完成.与Hibernate SessionFactory
等无关.
This property will register an OpenEntityManagerInViewInterceptor
, which registers an EntityManager
to the current thread, so you will have the same EntityManager
until the web request is finished. It has nothing to do with a Hibernate SessionFactory
etc.
这篇关于Spring Boot中的spring.jpa.open-in-view = true属性是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!