More DD examples for CMT
Option 1: Wildcard
Use a wildcard to say that all methods in the specified bean have the attribute in the <trans-attribute> tag.

Option 2: Individually-named methods
Specify each method of each CMT bean in the ejb-jar (unless you use the wildcard to indicate all methods of the specified bean class have the specified attribute).
Note
Here we have three different methods, in one bean, that all have the RequiresNew attribute.
<container-transaction>
<method>
<ejb-name>BigBean</ejb-name>
<method-name>foo</method-name>
</method>
<method>
<ejb-name>BigBean</ejb-name>
<method-name>go</method-name>
</method>
<method>
<ejb-name>BigBean</ejb-name>
<method-name>bar</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
<container-transaction>
<method>
<ejb-name>BigBean</ejb-name>
<method-name>doStuff</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>Note
This is a different transaction attribute -- Requires -- so here we list the method that uses Requires. Notice that we’re naming the same bean we used in the previous <container-transaction> element.

Don’t worry.
Chances are, your design will treat all versions of an overloaded method in the same way (for transactions). In the examples we’ve seen ...
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