是否存在与
Spring的@Transactional等效的EJB或JPA注释?
解决方法
等效的EJB3属性是javax.ejb.TransactionAttribute.
就像Spring的@Transactional注释一样,您可以通过将TransactionAttributeType传递给TransactionAttribute注释来控制事务“传播”,如:
@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() {...} }
容器管理的事务在Part IV of the Java EE 5 Tutorial中描述.