我正在阅读 java ee docs 我想问几个问题,以确保我已经理解了EJB-Transactions正在发生的事情。
1)文档说明了defaalt TransactionManagement
价值是 CONTAINER
和默认值 TransactionAttribute
价值是 REQUIRED
:如果是这样,我是对的,以下(Session)Bean执行其所有方法 CONTAINER
托管事务和属性 REQUIRED
?
@Stateless
public class MyBean{
public void methodA(){
...
}
public void methodB(){
...
}
}
2)文档说明: Container-managed transactions do not require all methods to be associated with transactions. When developing a bean, you can set the transaction attributes to specify which of the bean’s methods are associated with transactions.
如果我省略了 TransactionAttributeType
,它是不是自动设置为 REQUIRED
?是个 methodB
在以下Bean中没有与事务关联?
@Stateless
@TransactionManagement(CONTAINER)
public class MyBean{
@TransactionAttribute(MANDATORY)
public void methodA(){
...
}
public void methodB(){
...
}
}