Caching with mybatis is quite simple.
Follow the example from this website http://code.google.com/p/mybatis/wiki/Caches won’t work because they have some changes in packaging.
to use ehcache/hazelcast with mybatis just download the correct bundle from this link http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3DCache
put the following line into mybatis XML Mapper file.
with the default configuration Ehcache will work in a single node only if you want to use distributed cache function you’ll need to setup Terracotta Cluster.
with hazelcast you’ll get a full function distributed cluster. However, it depends on your configuration which can be included internally (JAR) or externally (Class path).
From what I notice there is no cache effect when the returned result is only one row (performance degraded), however, with multiple rows there is a significant performance gained.