Problem
StudyService.submit() performs 4-5 sequential database writes without transaction boundaries:
studyMapper.insertStudyRecord(...); // ①
studyMapper.insertWrongWord(...); // ②
studyMapper.updateUserStats(...); // ③
studyMapper.ensureUserBook(...); // ④
studyMapper.updateUserBookProgress(...); // ⑤
If step ③ fails (e.g. deadlock, connection timeout), steps ①② have already committed dirty data.
Proposed Solution
Add @Transactional to the submit() method and ensure the MyBatis mapper methods participate in the same transaction.
Affected
service/StudyService.java
- Potentially
mapper/StudyMapper.java (verify auto-commit settings)
Problem
StudyService.submit()performs 4-5 sequential database writes without transaction boundaries:If step ③ fails (e.g. deadlock, connection timeout), steps ①② have already committed dirty data.
Proposed Solution
Add
@Transactionalto thesubmit()method and ensure the MyBatis mapper methods participate in the same transaction.Affected
service/StudyService.javamapper/StudyMapper.java(verify auto-commit settings)