Annotation 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 ElementsModifier and TypeOptional ElementDescriptionorg.springframework.transaction.annotation.IsolationTransaction isolation level.org.springframework.transaction.annotation.PropagationTransaction propagation behaviour.booleanWhether the transaction is read-only.intTransaction timeout in seconds.Bean name of a specificPlatformTransactionManagerto use.
-
Element Details
-
propagation
org.springframework.transaction.annotation.Propagation propagationTransaction propagation behaviour.- Returns:
- propagation setting; defaults to
Propagation.REQUIRED
- Default:
REQUIRED
-
isolation
org.springframework.transaction.annotation.Isolation isolationTransaction isolation level.- Returns:
- isolation level; defaults to
Isolation.DEFAULT
- Default:
DEFAULT
-
timeout
int timeoutTransaction timeout in seconds.- Returns:
- timeout in seconds; defaults to
TransactionDefinition.TIMEOUT_DEFAULT(no explicit timeout)
- Default:
-1
-
readOnly
boolean readOnlyWhether 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:
trueto request a read-only transaction; defaults tofalse
- Default:
false
-
transactionManager
String transactionManagerBean name of a specificPlatformTransactionManagerto use.- Returns:
- bean name; defaults to
""which selects the primaryPlatformTransactionManagerin the context
- Default:
""
-