Referencing the topic how to clear mybatis cache manually by code I stumbled over a issue with TransactionalCache which is the only MyBatis cache type which gets NOT cleared by calling clear()
on every cache provided by sqlSessionFactory.getConfiguration().getCaches
In particular the member variables of org.apache.ibatis.cache.decorators.TransactionalCache
private Map<Object, Object> entriesToAddOnCommit;
private Set<Object> entriesMissedInCache;
are holding keys and values which should be chached on commit and which are not cached yet. So far so good.
In my optinion both should be cleared on cache.clear()
, but the responsible clear
method gets never invoked
@Override
public void clear() {
clearOnCommit = true;
entriesToAddOnCommit.clear();
}
Is this a bug or are there any explanation or suggestion how to flush TransactionalCache?