【发布时间】:2010-09-30 11:00:13
【问题描述】:
在以下设置中,方法 B 是否在(新)事务中运行?
一个 EJB,有两个方法,方法 A 和方法 B
public class MyEJB implements SessionBean
public void methodA() {
doImportantStuff();
methodB();
doMoreImportantStuff();
}
public void methodB() {
doDatabaseThing();
}
}
EJB 是容器管理的,methodB 在 requires_new 事务中,method A 在 required 事务中。因此:
<container-transaction id="MethodTransaction_1178709616940">
<method id="MethodElement_1178709616955">
<ejb-name>MyName</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</method>
<method id="MethodElement_1178709616971">
<ejb-name>MyName</ejb-name>
<method-name>methodB</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
现在让另一个 EJB 通过 EJB 方法调用来调用 methodA。 methodA 现在在事务中运行。从 methodA 对 methodB 的后续调用会在同一个事务中运行,还是在新事务中运行? (注意,这里是实际的代码。没有显式的对方法 B 的 ejb 调用)
【问题讨论】:
标签: jakarta-ee transactions ejb