2 Replies Latest reply on Nov 14, 2007 3:37 AM by dapeng wang

    SpringTransaction exception handling enhancement required

    dapeng wang Newbie

      Hi,

      currently if a tx will be rollbacked, the SpringTransaction class kind of swallow the root cause in the following code

      catch (TransactionSystemException e)
       {
       log.error("Exception cause:", e);
       throw new SystemException(e.getMessage());
       }
       catch (UnexpectedRollbackException e)
       {
       log.error("Exception cause:", e);
       throw new RollbackException(e.getMessage());
       }


      It is essential to pass the whole cause exception in SystemException and RollbackException instead of only a text message.

      My use case is the following:
      JSF delete action method tries to delete a row in the db. When the tx commits, it discovers the row can not be deleted because of foreign key constraint. I would like to have the ConstraintViolationException wrapped in the RollbackException, so that I have a chance to handle this exception later with the exception handler.

      In the current implmenetation, the RollbacklException with only text message and no cause stack will later be wrapped as an IllegalStateException, which is not helpful for exception handling at all.