Call stack of the checkOut() method
ut.begin() is called, and the transaction starts.
ut.begin() completes, and now the checkout() method is running in a transaction (tx A).
validateCredit() is called and runs in the same transaction as checkOut().
validateCredit() completes (pops off the stack) and the checkOut() method is still running in tx A.
checkInventory() is called and runs in the same transaction (tx A).
checkInventory() completes and pops off the stack. The transaction (tx A) is still open.
commit() is called, which ends the transaction.
commit() completes, and now checkOut() is running without a transaction.
doNonTxStuff() is called without a transaction.
Get Head First EJB now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.