Annotation Interface TransactionalResult


@DmxTransactionalBinding @InterceptorBinding @Inherited @Documented @Retention(RUNTIME) @Target({TYPE,METHOD}) public @interface TransactionalResult
Declarative transaction annotation for methods that return Result.

When applied to a CDI bean method, TransactionalDmxInterceptor intercepts the call and wraps the body in a JTA transaction. The transaction commits when the method returns Result.isOk() and rolls back when it returns Result.isError() or when an unchecked exception escapes.

Quick start

@ApplicationScoped
public class OrderService {

    @TransactionalResult
    public Result<Order, OrderError> createOrder(OrderRequest req) {
        return validate(req)
            .flatMap(this::persistOrder)
            .flatMap(this::notifyInventory);
    }

    // Always suspend any outer transaction and start a fresh one.
    @TransactionalResult(Transactional.TxType.REQUIRES_NEW)
    public Result<AuditEntry, String> audit(Event event) { ... }
}

Transaction semantics

  • Transactional.TxType.REQUIRED (default) — join an existing transaction or begin a new one.
  • Transactional.TxType.REQUIRES_NEW — always suspend any active transaction and begin a fresh one; the new transaction commits or rolls back independently.
  • Transactional.TxType.MANDATORY — require an active transaction; throw TransactionalException if none exists.
  • Transactional.TxType.SUPPORTS — join an active transaction if present; otherwise execute without one.
  • Transactional.TxType.NOT_SUPPORTED — suspend any active transaction and execute without one; resume it afterwards.
  • Transactional.TxType.NEVER — throw TransactionalException if a transaction is active.
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    jakarta.transaction.Transactional.TxType
    The transaction propagation type.
  • Element Details

    • value

      jakarta.transaction.Transactional.TxType value
      The transaction propagation type.

      Marked Nonbinding so that CDI selects the same interceptor regardless of the chosen Transactional.TxType; the interceptor reads the value at runtime.

      Default:
      REQUIRED