@Transactional एका method ला database transaction मध्ये गुंडाळते: method चालण्यापूर्वी Spring एक transaction उघडते आणि तो सामान्यपणे return झाल्यावर commit करते — किंवा throw झाल्यास rollback करते. आतून ते एक AOP proxy आहे, जो बहुतांश अडचणींचा स्रोत आहे.
मूलभूत वापर
{
{
accounts.debit(from, amount);
accounts.credit(to, amount);
}
}
