Skip to content

The query cache is not cleared after transaction rolls back to a savepoint #785

Open
@luozhenyu

Description

@luozhenyu
// 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);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions