Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 11. Transactions and Persistence > Seam-Managed Transactions

11.1. Seam-Managed Transactions

Transactions are enabled by default for all EJB3 session bean methods in an EJB3 application, so you don’t need to do anything special to put the confirm() method under a transaction. The transaction manager is started when an event handler thread starts (e.g., when the confirm() method is invoked). The transaction manager commits all the updates to the database at the end of the thread. Since the transaction manager tracks the thread, it manages the event handler method and all the nested method calls from inside the event handler.

If any database operation in the confirm() method fails and throws a RuntimeException, the transaction manager rolls back all database operations. For instance, if the hotel inventory reduction operation fails due to a database connection error, the booking save operation, which already executed, would be canceled as well. The database is returned to the state before the conversation, and Seam displays an error message instead of the confirmation number (see Figure 11.1). We discuss how to display a custom error page for the RuntimeException in Section 17.4; if you do not set up the custom error page, the server just displays the error stack trace in JBoss’s standard error page.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint