When using container managed transactions, the application usually just needs to demarcate any transactions. In general we do not need to explicitly commit or rollback a transaction: the container takes care of this. However sometimes we need to explicitly commit and rollback transactions even when using container managed transactions. We may want to use a cache with stateful session beans and commit the data when the cache is full rather than at the end of each transaction. To do this we need to implement the SessionSynchronization
interface. This is described in the next subsection. In the course of processing a business method we may need to abort a transaction. This is done using the SessionContext.setRollbackOnly()
method. This ensures the container will not commit the current transaction. We describe this in the "Doomed Transactions" subsection.
EJB 3 Developer Guide
By :
EJB 3 Developer Guide
By:
Overview of this book
Table of Contents (18 chapters)
EJB 3 Developer Guide
Credits
About the Author
About the Reviewers
Preface
Free Chapter
Introduction to the EJB 3 Architecture
Session Beans
Entities
Object/Relational Mapping
The Java Persistence Query Language
Entity Manager
Transactions
Messaging
EJB Timer Service
Interceptors
Implementing EJB 3 Web Services
EJB 3 Security
Annotations and Their Corresponding Packages
Customer Reviews