Listing 6.4. Implementing snag-it ordering using BMT
Scanning the code, you'll notice that the @TransactionManagement annotation spe-
cifies the value TransactionManagementType.BEAN as opposed to Transac-
tionManageMentType.CONTAINER , indicating that BMT is used this time . The
TransactionAttribute annotation is missing altogether because it's applicable only
for CMT. A UserTransaction , a JTA interface, is injected and used explicitly to
begin , commit , or rollback a transaction. The transaction boundary is
much simpler than the entire method and includes only calls that really need to be atomic.
The sections that follow discuss the code in greater detail, starting with getting a reference
to a javax .transaction.UserTransaction instance.
6.3.2. Getting a UserTransaction
The UserTransaction interface encapsulates the basic functionality provided by the
Java EE transaction manager. JTA has a few other interfaces used under different circum-
stances. We won't cover them here, because most of the time you'll be dealing with User-
Transaction . As you might expect, the UserTransaction interface is too intricate