6.7. Transaction issues in session EJBs

The EJB Specification provides mechanisms to support synchronization of stateful session beans with transactions. This is discussed in detail in Chapter 9. For now, note the following points.

  • Session EJBs can participate in database and messaging transactions, either controlled by the EJB itself or by the container. Transactionality is not the exclusive prerogative of entity EJBs.

  • Stateful session EJBs can begin transactions in one method and commit them in another. Stateless session EJBs can’t do this: A transaction begun in one method must be committed in the same method. The argument for this is subtle, but compelling. The only conceivable reason for beginning a transaction in one method and completing ...

Get Applied Enterprise JavaBeans™ Technology 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.