Search code examples
transactionsstatelessstateless-session-bean

@TransactionAttribute without @stateless or @stateful ? J2EE 6 - JBoss EAP 6


if I specify @TransactionAttribute on a class, but I do NOT specify @stateless or @stateful, what is the behavior ? Will this be a session bean, or will the @TransactionAttribute just be ignored. ??

@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class PhotosServiceImpl implements PhotosService

vs

@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class PhotosServiceImpl implements PhotosService 

Solution

  • Without @Stateless you can't inject it into other EJBs. If you instantiate it without doing injection, TransactionAttribute wouldn't kick in anyway.

    So yes, TransactionAttribute on a non EJB class will have no effect.