Yep. I've also tried every cache type with no results. Today i also
tried tracing the process' execution with a debugger, and i can
confirm that two identical queries generate the same CacheKey object,
but the getObject() call returns no items for it.
¿Could it be something i'm missing in the configuration? I've skipped
XMLs altogheter and i configured my MyBatis instance using the
Configuration class methods, as described on the documentation. This
is because my project requires to keep all the configuration
centralized on an external file - including database parameters.
I'd really love to paste some code here but since this is a commercial
project i'm unable to :( But, globally what i'm doing is:
- Instantiate an environment ("default"), using PooledDataSource over
a com.mysql.jdbc.Driver JDBC and a ManagedTransaction.
- Instantiate a Configuration object using this previous environment,
on which i've set cacheEnabled=true.
- Register aliases for all the classes that will hold query results
(registerAlias)
- Add all the mapper classes i'm using (addMapper)
- Instantiate a SQLSessionFactoryBuilder with this configuration
- Instantiate a SQLSession, which is the only one used through the
process (using ExecutorType.BATCH)
I've tried playing with the lazy loading options and useGeneratedKeys,
but nothing seems to make any difference.
Thanks in advance!