Open
Description
// assume I inserted a row with 2 columns(id = 1, value = 10);
mapper.insert(1, 10);
// Obviously, the result is 10;
int value = mapper.selectValueById(1);
// Then create a savepoint by Spring
Object savepoint = TransactionAspectSupport.currentTransactionStatus().createSavepoint();
// Update its value to 20
mapper.updateValueById(1, 20);
// Select its value, the value is 20
int value = mapper.selectValueById(1);
// Rollback to savepoint, the value is 10 in database now
TransactionAspectSupport.currentTransactionStatus().rollbackToSavepoint(savepoint);
// Select its value again, but the value is still 20 which is retrieved from local cache
int value = mapper.selectValueById(1);