Annotation Interface TransactionalResult


@Target(METHOD) @Retention(RUNTIME) @Documented public @interface TransactionalResult
Declarative transaction annotation for methods that return Result.

When applied to a method, DmxTransactionalAspect intercepts the call and runs the body inside a Spring-managed 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

@Service
public class OrderService {

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

Requires DmxTransactionalAspect to be registered as a Spring bean and @EnableAspectJAutoProxy (or equivalent) active in the application context.

See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    org.springframework.transaction.annotation.Isolation
    Transaction isolation level.
    org.springframework.transaction.annotation.Propagation
    Transaction propagation behaviour.
    boolean
    Whether the transaction is read-only.
    int
    Transaction timeout in seconds.
    Bean name of a specific PlatformTransactionManager to use.
  • Element Details

    • propagation

      org.springframework.transaction.annotation.Propagation propagation
      Transaction propagation behaviour.
      Returns:
      propagation setting; defaults to Propagation.REQUIRED
      Default:
      REQUIRED
    • isolation

      org.springframework.transaction.annotation.Isolation isolation
      Transaction isolation level.
      Returns:
      isolation level; defaults to Isolation.DEFAULT
      Default:
      DEFAULT
    • timeout

      int timeout
      Transaction timeout in seconds.
      Returns:
      timeout in seconds; defaults to TransactionDefinition.TIMEOUT_DEFAULT (no explicit timeout)
      Default:
      -1
    • readOnly

      boolean readOnly
      Whether the transaction is read-only.

      A read-only hint allows the underlying JDBC driver or ORM to apply optimizations (e.g., skip dirty checking, use a read replica). It does not prevent writing statements — enforcement depends on the actual transaction manager and data source.

      Returns:
      true to request a read-only transaction; defaults to false
      Default:
      false
    • transactionManager

      String transactionManager
      Bean name of a specific PlatformTransactionManager to use.
      Returns:
      bean name; defaults to "" which selects the primary PlatformTransactionManager in the context
      Default:
      ""