0
votes

I have a stateless EJB that using container managed transactions. Can I have a method in that EJB that can use bean managed transaction. I know I can make the whole EJB to use the bean managed transactions by using the attribute @TransactionManagement(TransactionManagementType.BEAN)

1

1 Answers

1
votes

No, you cannot switch between container-managed and bean-managed transactions on a per-method basis. You either need to use entirely bean-managed transactions, or you would need to split your logic into two separate EJBs.

(I cannot think of a reason why this must be the case. I think the EJB spec could have made BEAN be just another transaction attribute type rather than having a BMT/CMT distinction. Perhaps it was felt that would make the transaction model too complicated, or there weren't sufficient use-cases to try that approach.)