Search code examples
transactionsejb

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 client with transaction attribute NOT_SUPPORTED and transaction management type BEAN calling method with transaction attribute REQUIRES_NEW

@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(){}


}

Solution

  • Answered by Leonardo, myBean.transactionalMethod will run in its own transaction since we call it via @Remote