EJB 3.0 Singleton with transaction attribute NOT_SUPPORTED and transaction management type BEAN calling method with transaction attribute REQUIRES_NEW
EJB 3.0 Singleton with transaction attribute NOT_SUPPORTED and transaction management type BEAN calling method with transaction attribute REQUIRES_NEW
具有事务属性NOT_SUPPORTED的EJB 3.0单例客户端和具有事务属性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(){}
}
Leonardo 回答,myBean.transactionalMethod 将 运行 在它自己的事务中,因为我们通过 @Remote
调用它
具有事务属性NOT_SUPPORTED的EJB 3.0单例客户端和具有事务属性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(){}
}
Leonardo 回答,myBean.transactionalMethod 将 运行 在它自己的事务中,因为我们通过 @Remote
调用它