Backend Development Spring Boot Subjective
Oct 03, 2025

What is @Transactional annotation? Explain with example.

Detailed Explanation
@Transactional manages database transactions:\n\n@Service\npublic class BankService {\n @Transactional\n public void transferMoney(Long fromId, Long toId, BigDecimal amount) {\n Account from = accountRepo.findById(fromId);\n Account to = accountRepo.findById(toId);\n from.debit(amount);\n to.credit(amount);\n accountRepo.save(from);\n accountRepo.save(to);\n }\n}
Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback