Environment
- Spring Boot 3.5 / Spring Batch 5.x
- MyBatis 3.5.x / MyBatis-Spring 3.0.x
- Java 17
- DB: Altibase 7
Summary
When using MyBatisBatchItemWriter with dynamic SQL, MyBatis internally triggers a rollback if the BatchResult count does not match expectations:
InvalidDataAccessResourceUsageException: Expected 1 but number of BatchResult objects returned was 3
This rollback only appears at DEBUG level, so in typical production settings (INFO level), there is zero visibility into:
- why rollback happened
- which SQL caused it
- whether the issue is in reader / processor / writer
I could only discover this because my custom MyBatis Interceptor executed twice, which led me to enable DEBUG logs.
Using assertUpdates(false) prevents the rollback, but the root cause is extremely difficult to diagnose due to lack of visible logging.
Expected
Rollback due to BatchResult mismatch should be logged at INFO or WARN, not only DEBUG.
Or provide clearer diagnostics when dynamic SQL results in unexpected batch update counts.
Actual
| Item |
Result |
| Rollback occurs |
Yes |
| Visible at INFO level |
No |
| Debug log shows cause |
Yes |
| Batch meta-table shows rollback only |
Yes |
Request
Please consider elevating this rollback-related message to INFO/WARN or providing clearer visibility when dynamic SQL causes unexpected BatchResult counts in batch environments.