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

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

问题描述

我在 Spring Boot 文档中看到了用于 JPA 配置的 spring.jpa.open-in-view=true 属性.

I saw spring.jpa.open-in-view=true property in Spring Boot documentation for JPA configuration.

  • 如果根本没有提供此属性的 true 默认值吗?;
  • 这到底有什么作用?我没有找到任何好的解释;
  • 它是否让您使用 SessionFactory 而不是 EntityManagerFactory?如果是,我如何告诉它允许我使用 EntityManagerFactory 代替?
  • Is the true default value for this property if it's not provided at all?;
  • What does this really do? I did not find any good explaining for it;
  • Does it make you use SessionFactory instead of EntityManagerFactory? If yes, how can I tell it to allow me to use EntityManagerFactory instead?

谢谢!

推荐答案

这个属性会注册一个 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天全站免登陆