does this mean something like the pseudo code below?
Yes, almost:
//start transation
entityManager.joinTransaction()
//entity operations
//end transaction
would do. In BMT you have to code the
//start transaction
// end transaction
parts, while in CMT the container handles these parts automatically.
Please note that there are two types of extended persistence contexts:
- persistence context of an application managed entity manager
- persistence context of an container managed entity manager of a stateful session bean with persistence type EXTENDED
Answer a) holds for both, but the explanation
Unless an extended persistence context is manually enlisted in a transaction, the entities won't go into the database.
only holds for application managed entity managers: An extended persistence context of an container managed entity manager will be automatically associated with an active transaction.
And there is another exception to the quoted explanation: If an application managed entity manager is created within an transaction, its persistence context is automatically associated with the transaction. No joinTransaction() is needed in this situation. But answer a) is still right.