Is there an EJB or JPA annotiation that is equivalent to Spring's @Transactional ?
The equivalent EJB3 attribute is javax.ejb.TransactionAttribute
.
Just like Spring's @Transactional
annotation, you can control the transaction 'propagation' by passing a TransactionAttributeType
to the TransactionAttribute
annotation, like:
@TransactionAttribute(NOT_SUPPORTED)
@Stateful
public class TransactionBean implements Transaction {
...
@TransactionAttribute(REQUIRES_NEW)
public void firstMethod() {...}
@TransactionAttribute(REQUIRED)
public void secondMethod() {...}
public void thirdMethod() {...}
public void fourthMethod() {...}
}
Container managed transactions are described in Part IV of the Java EE 5 Tutorial.