【发布时间】:2013-11-18 02:46:24
【问题描述】:
如果我在 EJB bean 中有两个方法,一个具有 NOT_SUPPORTED 的 Transaction 属性,需要使用 REQUIRED 调用另一个,如果我通过注入的 bean 进行调用,我是否可以期望事务启动:
@Stateless
@LocalBean
public class LeBean {
@EJB LeBean bean;
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void someMethod(){
...
bean.otherMethod();
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void otherMethd(){
...
}
}
或者我可以像这样在本地拨打电话吗:
@Stateless
@LocalBean
public class LeBean {
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public void someMethod(){
...
otherMethod();
}
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void otherMethd(){
...
}
}
现在someMethod() 在到达otherMethod() 之前需要很长时间来处理信息,因此事务超时,即使我已将 NOT_SUPPORTED 声明为第一种方法的事务属性。
【问题讨论】: