Call stack of the checkOut() method

  1. ut.begin() is called, and the transaction starts.

    image with no caption
  2. ut.begin() completes, and now the checkout() method is running in a transaction (tx A).

    image with no caption
  3. validateCredit() is called and runs in the same transaction as checkOut().

    image with no caption
  4. validateCredit() completes (pops off the stack) and the checkOut() method is still running in tx A.

    image with no caption
  5. checkInventory() is called and runs in the same transaction (tx A).

    image with no caption
  6. checkInventory() completes and pops off the stack. The transaction (tx A) is still open.

    image with no caption
  7. commit() is called, which ends the transaction.

    image with no caption
  8. commit() completes, and now checkOut() is running without a transaction.

    image with no caption
  9. 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.