rrezartprebreza/spring-boot-skills / skills/spring-boot-3/transactional-patterns
transactional-patterns
VerifiedUse when defining or debugging Spring Boot 3 database transaction boundaries, rollback, propagation, optimistic-lock retries, or commit-bound events. For duplicate HTTP commands use idempotency-patterns; for reactive transactions use webflux-reactive-patterns.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 9.5 KB |
| agents/openai.yaml | config | 211 B |
| examples/bad-transactional-service.java | other | 1.6 KB |
| examples/good-transactional-service.java | other | 1.7 KB |
| templates/TransactionalOrderService.java | other | 2.7 KB |
examples/bad-transactional-service.java
View on GitHub// BAD — every common @Transactional mistake
@Service
public class OrderService {
@Autowired
private OrderRepository orderRepository;
public Order findById(UUID id) { // ambiguous not-found contract
return orderRepository.findById(id).orElse(null);
}
@Transactional
public void processOrders(List<UUID> orderIds) {
for (UUID id : orderIds) {
this.processSingle(id); // joins outer TX; no independent transaction
}
}
@Transactional(propagation = Propagation.REQUIRES_NEW) // never reached via self-invocation
private void processSingle(UUID id) { // private method — proxy can't intercept
Order order = orderRepository.findById(id).orElseThrow();
order.process();
}
@Transactional
public void createOrder(CreateOrderRequest request) {
try {
Order order = Order.create(request.customerEmail());
orderRepository.save(order);
riskyExternalCall(order);
} catch (Exception e) {
log.error("Failed", e); // hides failure; may commit or remain rollback-only
}
}
@Transactional // missing rollbackFor = Exception.class
public void updateOrder(UUID id, UpdateOrderRequest request) throws BusinessException {
Order order = orderRepository.findById(id).orElseThrow();
order.update(request);
// checked exception won't trigger rollback without rollbackFor
externalService.notify(order);
}
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |