Summary of Bean-managed demarcation
Bean-managed (BMT)
Used by stateless and stateful session beans.
Used by message-driven beans.
Must NOT be used by entity beans.
Can be used to reduce the scope of a transaction, which can help performance.
Can be used to keep a transaction open across multiple invocations to a stateful method bean.
Can be used by a message-driven bean to acknowledge a method even though the transaction ends in a rollback.
Message-driven beans must complete a transaction by the end of onMessage().
Stateless session beans must complete a transaction by the end of the business method in which the transaction was started.
The BMT bean must not start a transaction without first ending the previous transaction. (Remember, no nested transactions in EJB!)
The BMT bean must not use the getRollbackOnly() and setRollbackOnly() methods of EJBContext.
The BMT bean can call the setRollbackOnly() method on the UserTransaction.
The bean gets a UserTransaction from the bean’s EJBContext.
Propagation of transactions in a BMT bean are one-way: a bean-started transaction can propagate out to other beans, but no transaction can ever be propagated in to a bean using BMT.
The UserTransaction interface does NOT have a getRollbackOnly() method, but BMT beans can call getStatus() to find out if someone in the transaction has called setRollbackOnly().
The getStatus() method returns an int representing ...
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