在以下设置中,方法 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 调用)