A use case can load an aggregate, run domain logic, persist changes, and publish events; those steps need one atomic boundary. The Architecture Kernel’s @Transactional annotation declares that intent without importing Spring into the application core. A Spring Boot starter and custom transaction interceptor connect the annotation to Spring’s transaction infrastructure and interpret Either failures for rollback. section 6.3 section 6.6
Place the annotation on the handler that orchestrates the use case—not on repositories, adapters, domain services, or input adapters. That handler defines the atomic unit of work. Using Spring’s own annotation there couples the application core to Spring and makes isolated handler tests depend on Spring’s transaction test infrastructure. section 6.3.4
Set the boundary according to the handler’s role:
- Query handlers use @Transactional(readOnly = true); a repository write inside the query is rejected at the database level. section 6.3.5
- Command handlers use @Transactional without the readOnly flag. section 6.3.5
Publishing an article
PublishArticleHandler can load the article, invoke domain behavior, persist the new state, and collect an ArticlePublished event within one transaction. Success commits the state; failure rolls it back. section 6.3.5
Table 6.2 Transaction boundary placement
|
Layer
|
@Transactional?
|
Why
|
|
Handler
(@ApplicationService
)
|
Yes
|
Orchestrates the full use case; atomic unit of work
|
|
Repository interface
|
No
|
Called within the handler's transaction; no independent boundary
|
|
Repository adapter
|
No
|
Implementation detail; inherits handler's transaction
|
|
Domain service
|
No
|
Called by the handler; operates within its transaction
|
|
Input adapter (e.g. controller)
|
No
|
Outside the hexagon; not part of the business transaction
|
Use the layer-by-layer placement table to check where the transaction boundary belongs. section 6.3.4



