Class TransactionHandler


  • public final class TransactionHandler
    extends Object
    • Constructor Detail

      • TransactionHandler

        public TransactionHandler()
    • Method Detail

      • handleExceptionNoThrow

        public static void handleExceptionNoThrow​(jakarta.transaction.Transactional transactional,
                                                  Throwable t,
                                                  jakarta.transaction.Transaction tx)
                                           throws IllegalStateException,
                                                  jakarta.transaction.SystemException
        For cases that the transaction should be marked for rollback ie. when RuntimeException is thrown or when Error is thrown or when the exception si marked in Transactional.rollbackOn() then Transaction.setRollbackOnly() is invoked.
        Throws:
        IllegalStateException
        jakarta.transaction.SystemException
      • endTransaction

        public static void endTransaction​(jakarta.transaction.TransactionManager tm,
                                          jakarta.transaction.Transaction tx,
                                          RunnableWithException afterEndTransaction)
                                   throws Exception

        It finished the transaction.

        Call TransactionManager.rollback() when the transaction si marked for Status.STATUS_MARKED_ROLLBACK. otherwise the transaction is committed. Either way there is executed the Runnable 'afterEndTransaction' after the transaction is finished.

        Throws:
        Exception