【问题标题】:Which one is correct about Spring JPA Support关于 Spring JPA 支持哪一项是正确的
【发布时间】:2021-02-12 16:44:59
【问题描述】:

请帮助理解以下哪项是正确的。

  1. Spring 支持结合本地或全局事务管理 JPA PersistenceContext。
  2. 通过在 EntityManagerFactoryBean 上设置供应商适配器属性来指定 JPA 提供程序
  3. 映射本地事务时,JPATransactionManager 使用 JPA EntityManager 来完成这项工作。

在我看来,这三个陈述都是不正确的。 原因:

  1. 本地事务中的 JPA PersistenceContext 支持。供全球使用的 JTA。
  2. 在 localEntityManagerFactoryBean 上使用适配器属性
  3. JPA 使用 EntityManagerFactory 来完成工作。

请帮忙。

【问题讨论】:

    标签: spring jpa transactions


    【解决方案1】:

    我不确定我是否正确。我愿意就这三点进行讨论。

    1. JPA 持久性上下文可以在 JTA 中传播。 这是来自 Oracle 的参考。但我认为它适用于Spring。 https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html

    2. 在 EntityManagerFactoryBean 中指定了供应商适配器。 https://www.javadoc.io/doc/org.springframework/spring-orm/4.0.5.RELEASE/org/springframework/orm/jpa/JpaVendorAdapter.html

    3. JPATransactionManager 使用 EntityManagerFactory 来处理事务。 https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/orm/jpa/JpaTransactionManager.html

    【讨论】:

      猜你喜欢
      • 2018-01-29
      • 2017-10-21
      • 2013-09-17
      • 1970-01-01
      • 1970-01-01
      • 2013-08-20
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多