- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我是 Spring 和 JPA 的新手,我正在学习 Spring Core 认证,我对学习 Material 中的这个问题有一些疑问:
Are you able to participate in a given transaction in Spring while working with JPA?
我认为答案是否定的,因为我知道 JPA 提供了配置选项,因此 Spring 可以管理事务和 EntityManager,但我绝对不确定是否正确理解了这个问题。 参与给定交易的确切含义。
一开始我解释为与现有事务交互,这是不可能的,因为事务对于定义而言是原子的。
但是我在文档中找到了这些信息:
透明地参与 Spring 驱动的事务:
只需使用 Spring 的 FactoryBeans 之一来构建实体管理器工厂
使用@PersistenceContext 注入(inject) EntityManager 引用
定义一个事务管理器:JpaTransactionManager
并展示这个例子:
public class JpaOrderRepository implements OrderRepository {
private EntityManager entityManager;
@PersistenceContext
public void setEntityManager (EntityManager entityManager) {
this. entityManager = entityManager;
}
public Order findById(long orderId) {
return entityManager.find(Order.class, orderId);
}
}
那么它与我原来的问题有关吗?怎么办?
@PersistenceContext 注释的具体作用是什么?EntityManager 对象的确切作用是什么?
谢谢
最佳答案
我也在学习认证,在阅读您的帖子后,我认为 Spring 文档的这段摘录就是这个问题的全部内容:
Spring JPA also allows a configured JpaTransactionManager to expose a JPA transaction to JDBC access code that accesses the same DataSource, provided that the registered JpaDialect supports retrieval of the underlying JDBC Connection. Out of the box, Spring provides dialects for the EclipseLink, Hibernate and OpenJPA JPA implementations. See the next section for details on the JpaDialect mechanism.
同时检查 What transaction manager should I use for JBDC template When using JPA ?
关于java - 在使用 JPA 的 Spring 中参与给定事务的确切含义是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29343847/
最近我有兴趣加入一个开源的 p2p 文件共享项目。我对这个主题的了解不是那么具体,我的意思是我了解安全、网络、p2p 基础知识,但我仍然不知道从哪里开始同时了解全局和实际细节。简而言之,推荐的资源是什
自从百度发布超链接算法升级公告之后,看到很多SEO大神对于外链对排名的作用就更加讳莫如深,而作为个人站长,大家对于外链的看法各执一词。像高质量外链、外链作用、外链对排名的影响等等话题,各大论坛讨论的
老实说,这是一个家庭作业问题,但我已经浪费了好几个小时,而且无法正确解决。它返回错误数量的结果或错误的数据: 我需要选择参与指导电影和/或在电影中表演的每个人以及他们所做的次数,如果至少 5 次。 有
我只是想知道如何为我的应用程序激活 (RED) 东西。我在我的应用程序中添加了一个新的更新,看看是否有参与的复选标记,但没有。是否可能是 Apple 决定哪些应用“有资格”加入该计划? 提前致谢:)
在我的代码中我有这样的东西: struct SomeStruct { int test1; int test2; float test3; float test4; }; std::v
我有一个继承自 UIControl 的自定义类,用于获取触摸事件。它基本上是其他控件的集合,这些控件充当一个整体。我正在将我的应用程序从 xibs 转换为 Storyboard。除了这个之外,它基本上
我正在使用 expo 制作一个 React 应用程序,我想允许子元素出现在我的 TopicSection 元素中。我关注了this guide为了允许 JSX 元素中的子元素,并编写了以下代码。我尝试
根据 Uber 文档,应通过以下方式推荐新用户:“https://m.uber.com/sign-up?client_id=YOUR_CLIENT_ID ” 那么,有没有办法通过以下方式引用使用 oA
更新:这个问题至少通过 -XX:+UseCountedLoopSafepoints 和等于或高于 JDK 1.8.0_92 的 JVM 版本(使用 _161 测试)的组合粗略地解决了。 原创:包含 J
我有一个 Maven 项目,它编译为 webapp,具有标准 Maven war 布局。我正在尝试向同一个项目添加方面,但当部署为 Tomcat 上的 war 时,这些方面不会被触发。如果我将项目部署
现在 Facebook 会列出生日等事件的参与度,我想在我的网站上显示参与度。 有什么方法可以通过图形 API 让 friend 参与进来吗? 最佳答案 https://graph.facebook.
我正在安装 Engage! 我按照此处的安装说明进行操作:http://engagecsm.com/readme 我做的安装步骤: 添加互动!到应用程序的 Gemfile:gem 'engagecsm
对于以下实体关系结构,我正在努力弄清楚 LOAN 和 ITEM 实体之间的关系是否有效? LOAN 的弱实体使用 'loan_dateLeant' 的部分键和来自 CUSTOMER 和 ITEM 的主
我目前正在研究涉及 VBA 和 IE 的自动化流程。随着我的代码正在执行的多项操作,一切都与时俱进。问题是当我接近一个有 2 个下拉列表的部分时,在第一个下拉列表中做出某些选择后出现第二个下拉列表。
我有以下 Spring Integration 配置。我在这里所做的是dequeuing 来自主题的消息并在转换后将其发送到某个 HTTP 位置。 JMS 连接工厂 配置如下:
我正在使用 python-firebase在我的堆栈中记录点击次数和其他事件数据。它工作正常,但时不时地抛出这个堆栈跟踪: 'ConnectionError(MaxRetryError("HTTPSC
我是一名优秀的程序员,十分优秀!