users@jta-spec.java.net

[jta-spec users] new TransactionalException

From: Paul Parkinson <paul.parkinson_at_oracle.com>
Date: Mon, 4 Feb 2013 15:14:36 -0500

Hello,

I wanted to explicitly call out a new TransactionalException that is in the latest rev of the spec, the javadoc for which is below.

It serves as a RuntimeException extension wrapping exceptions thrown by the transactional interceptors and allows for closer alignment with the exception handling behavior that occurs in EJB (eg the runtime exceptions EJBTransactionRequiredException and EJBException that result in transactions being marked for rollback) as a default.

Please replies with any comments or questions if you would.

Thanks,
Paul

Class TransactionalException

public class javax.transaction.cdi.TransactionalException extends java.lang.RuntimeException
{

public TransactionalException(String s, Throwable throwable); }

RuntimeException used to rethrow Exceptions thrown from Transactional annotation interceptors implementation.

This results in the transaction being marked for rollback by default.

The original Exception is set as the nested exception and includes TransactionRequiredException for the case where a bean with TxType.MANDATORY is called outside a transaction context, InvalidTransactionException for the case where a bean with TxType.NEVER is called inside a transaction context, and various commit-time exceptions such as RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, and SystemException.

Constructors

• TransactionalException
public TransactionalException(String s, Throwable throwable)

Create an TransactionalException with a given string and nested Throwable.