@Transactional: declarative transaction management — Spring tự động begin, commit, rollback.
- Attributes:
propagation(REQUIRED, REQUIRES_NEW, NESTED),isolation(READ_COMMITTED, SERIALIZABLE),readOnly(optimization),rollbackFor(exception nào gây rollback). - Default: rollback khi unchecked exception, commit khi checked.
- Spring tạo proxy bao quanh method để intercept.
- Lưu ý quan trọng: internal call (gọi method trong cùng class) bypass proxy — phải inject self reference hoặc refactor để transaction hoạt động đúng.