1

我认为最好用一张图片来描述这个问题。我希望有一个人可以帮助我。谢谢替代文字

4

2 回答 2

1

我同意 Pascal,如果来自 EJB1 的两个调用在同一个事务中,那么很明显 (2) 看不到 (1) 执行的更改,因为它们是在另一个事务中执行的(当然,假设是合理的事务隔离级别)

1. EJB1 transaction (TX1) starts
2.  EJB1.(1) called
3.   EJB2.update row started => TX1 is suspended and
     a new transaction, TX2, is started
4.   The update is performed
5.   TX2 commits
6.  TX1 is resumed - it can't see changes by TX2 because it's isolated from
    changes performed by other transactions during its "life"
7.  EJB1.(2) invokes EJB2.find row withing the context of TX1 => can't see TX2's changes
8. TX1 commits
于 2010-05-03T21:57:05.473 回答
1

我不确定您是否提供了所有上下文,但如果 (1) 和 (2) 在同一个事务中运行,我会说该实体位于 L1 缓存中,这就是问题所暗示的,并且在“更新行”是不可见的,因为它们是在另一个持久性上下文(嵌套事务)中完成的,因此需要refresh从数据库中获取实例的状态。

于 2010-05-01T01:12:11.650 回答