具有事务属性NOT_SUPPORTED的EJB 3.0 Singleton和具有事务属性REQUIRES_NEW的事务管理类型BEAN调用方法

时间:2016-12-13 14:50:57

标签: transactions ejb

具有事务属性NOT_SUPPORTED的EJB 3.0 Singleton客户端和具有事务属性REQUIRES_NEW的事务管理类型BEAN调用方法

@Local
@Singleton(name = "MySingleton", mappedName = "MySingleton")
@Startup
@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER)
@Lock(LockType.READ)
@TransactionManagement(value = TransactionManagementType.BEAN)
@TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)
public class MySingleton
{
public void call()
{
MyBean myBean = serviceLocator.lookup(MyBean.class);
myBean.transactionalMethod();
}
}

@Remote
@Stateless(mappedName = "MyBean", name = "MyBean")
public class MyBean
{

@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public MyObject transactionalMethod(){}


}

1 个答案:

答案 0 :(得分:0)

Leonardo回答,myBean.transactionalMethod将在自己的事务中运行,因为我们通过@Remote调用它