相关疑难解决方法(0)

本地方法调用中的EJB事务

在以下设置中,方法B是否在(新)事务中运行?

EJB,有两种方法,方法A和方法B.

public class MyEJB implements SessionBean
    public void methodA() {
       doImportantStuff();
       methodB();
       doMoreImportantStuff();
    }

    public void methodB() {
       doDatabaseThing();
    }
}
Run Code Online (Sandbox Code Playgroud)

EJB是容器管理的,require_new事务中的methodB和所需事务中的方法A. 从而:

<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>
Run Code Online (Sandbox Code Playgroud)

现在让另一个EJB调用方法A与EJB方法调用.methodA现在在一个事务中运行.从methodA对methodB的后续调用是在同一个事务中运行,还是在新事务中运行?(记住,这是实际的代码.没有明确的ejb调用方法B)

ejb transactions java-ee

20
推荐指数
3
解决办法
2万
查看次数

标签 统计

ejb ×1

java-ee ×1

transactions ×1