O'Reilly logo

EJB 3.1 Cookbook by Richard M. Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling errors in a transaction

When an error occurs during the execution of a transaction, the transaction may or may not need to be rolled back. It all depends on the nature of the error. Exceptions are classified as either checked exceptions, a java.lang.Exception derived class, or unchecked exceptions, a java.lang.RuntimeException derived class.

If an unchecked exception is thrown, a transaction is automatically rolled back. For checked exceptions, the UserTransaction's rollback method or the SessionContext's setRollbackOnly method are used to explicitly force a rollback.

Checked exceptions are considered to be application exceptions while unchecked exceptions are system exceptions. However, an application can declare its own unique exceptions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required