How do I make (or get) a transaction?
Two ways: code it or declare it
The container manages your transactions, but you have to tell it how. You can either put transaction code in your bean class, or you can put transaction declarations in the DD. By far, the most common approach is to use the DD, because it’s simpler, supports bean reuse, and is the only way you can do transactions for entity beans. By putting transaction information in the DD instead of in code, you can deploy the same bean multiple times and get different transaction behavior each time without ever touching the code!
Write transaction code in your bean.

OR
Declare transactions in the DD.

Note
You can’t use BOTH in the same bean! You can’t mix BMT and CMT in one bean.
You CAN have a combination of BMT and CMT beans in the same ejb-jar, but each bean must have only one transaction type. On the exam, if you see transaction code in a bean, make sure that if you see the DD for that bean, it says:
<transaction-type> Bean </transaction-type>
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access