I want to migrate from XML configuration to Java configuration.
sqlSessionFactory.getConfiguration().setEnvironment(new Environment("development", new org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory(), getDataSouroce()));
I managed to replace all <environments>
section with Java configuration (I have removed <environments>
from XML configuration file), but I can't get rid of:
<mappers><mapper resource="mailbox/db/map/FileMapper.xml"/> </mappers>
I tried to write:
sqlSessionFactory.getConfiguration().addMapper(FileMapper.class);
but there are exceptions:
SqlSession sqlSession = MyBatisConnectionFactory.instance.getSqlSessionFactory().openSession();
FileExample fe = new FileExample();
Criteria f = fe.createCriteria().andIdBetween(0L, 5L);
FileMapper mapper = (FileMapper) sqlSession.getMapper(FileMapper.class);
List<File> allRecords = mapper.selectByExample(fe);
// Mapped Statements collection does not contain value for mailbox.db.dao.FileMapper.selectByExample