Class TransactionExecuter

java.lang.Object
com.polarion.platform.TransactionExecuter

public final class TransactionExecuter extends Object
This class simplifies the execution of transactions. Recommendation: Use instances of this executor instead of the two static methods. Instances can be obtained using ITransactionService.execute(). Note: The executor instance creates read-only transactions by default (see write()).
Since:
3.5.2
  • Constructor Details

  • Method Details

    • write

      @NotNull public TransactionExecuter write()
      By default the transactions are read-only. Use this method to execute write transactions by this executor.
      Since:
      3.18.0
    • reuseExistingTransaction

      @NotNull public TransactionExecuter reuseExistingTransaction()
      By default the executor will fail if its terminal method is executed in a transaction context. If that is the case, use this method to reuse the existing transaction. In this scenario, the executor will not be able to influence the transaction type (read-only or write), and write() calls will be ignored.
      Since:
      3.18.0
    • runnable

      public void runnable(@NotNull Runnable runnable)
      Executes the runnable in a transaction. This is a terminal method for this executor. Multiple terminal methods can be called to execute multiple transactions using the same executor.
      Since:
      3.18.0
    • supplier

      @Nullable public <R> R supplier(@NotNull Supplier<R> supplier)
      Executes the supplier in a transaction and returns its result. This is a terminal method for this executor. Multiple terminal methods can be called to execute multiple transactions using the same executor.
      Since:
      3.18.0
    • execute

      public static <T> T execute(RunnableWEx<T> runnable)
      Executes the runnable inside the transaction. Recommendation: Use the executor instance instead of this static method wherever possible.
    • executeSafely

      public static <T> T executeSafely(@NotNull RunnableWEx<T> runnable)
      Executes the runnable inside the transaction. It will not create a new transaction if one exists or cannot be created or when the platform is not initialized. (So the invocation will never fail due to a transaction-related problem.)

      Recommendation: Use the executor instance instead of this static method wherever possible.

      Since:
      3.7.1
      See Also: