Things you must NOT do with BMT

image with no caption
  1. A BMT bean must NOT start a transaction before ending the current transaction.

    image with no caption

    Brain Power

    Imagine the implications of starting a new transaction before ending the current one. What might happen if you were allowed to do this?

    Note

    Nested transactions are not allowed in EJB!

    You’re expected to know what the term “nested transaction” means, and what it might look like in code.

  2. A BMT stateless session or message-driven bean must NOT complete a transactional method without ending the transaction.

    image with no caption

    Brain Power

    Why are stateful session beans allowed to end a method without ending the transaction?

    For a stateful bean, can you think of a scenario where you might want to do this (leave the transaction open)?

    What might go wrong if you do this?

    Note

    Only STATEFUL session beans can leave a transaction open at the end of a method.

BMT transactions are one way: they can propagate out to a CMT bean, but no other transaction can propagate in to a BMT bean

Both BMT and CMT bean transactions propagate into a CMT bean.

image with no caption

A CMT bean can run in transactions coming from both CMT and BMT beans. ...

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.