Spring Boot中的spring.jpa.open-in-view = true属性是什么? [英] What is this spring.jpa.open-in-view=true property in Spring Boot?

查看:1998
本文介绍了Spring Boot中的spring.jpa.open-in-view = true属性是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆