A tip on using user transaction on Mybatis

When using transation on Mybatis, there are 3 ways. Container managed transaction - JEE engine manages transaction User managed transaction - transaction is controlled by user source code Spring managed transaction - transaction is controlled by Spring Transaction policy I usually use Spring managed or container managed transaction. But sometimes, I need to control transaction … Continue reading A tip on using user transaction on Mybatis

Some points to consider when using Mybatis cache

When using Mybatis cache, there are some points to consider. Local session cache lifecycle Local session cache is enabled with default option Cache boundary is for all the queries within a SqlSession An item is cached when querying a record The item is reused when querying with the same parameter Cache is flushed when insert/update/delete … Continue reading Some points to consider when using Mybatis cache

Using Ehcache instead of Mybatis internal cache

Ehcache is a very robust in-memory cache. In production, Ehcache could be better solution for Mybatis cache (More on Mybatis internal cache) How to use Ehcache as Mybatis cache (2nd level cache) You can set Mybatis 2nd level cache (Global cache) as 3rd party. (You can not change local session cache type) Import required library … Continue reading Using Ehcache instead of Mybatis internal cache

Integrating Mybatis with Spring

Spring framework does not support Mybatis internally. Instead, mybatis-spring project supports integration of Mybatis with Spring. This article is based on Spring 4.3.16 and Mybatis 3.4.6. (As of writing this article, Spring 5.1.x still don't support Mybatis internally) You can download the sample project here. Test table for the sample Test Mybatis mapper xml Required … Continue reading Integrating Mybatis with Spring