Search code examples
mybatisibatis

TransactionalCacheManager and how to get TransactionalCache and clear


It is possible to take the specific TransactionalCache per transaction and invoke clear? I'm working with spring context but seems that the transactional cache manager is out of it.


Solution

  • It is not possible now (the current version is 3.4.6).

    TransactionalCache is a private field of the TransactionCacheManager which is in turn a private field of the CachingExecutor.

    The cache is only cleared during queries and updates when mapper configuration (flushCache attribute and query type) instructs mybatis to do so.