1
XML構成からJava構成に移行したいと考えています。JavaのmyBatis構成へのマッパーの追加
sqlSessionFactory.getConfiguration().setEnvironment(new Environment("development", new org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory(), getDataSouroce()));
私は(私はXML設定ファイルから<environments>
を削除した)は、Javaの設定で、すべての<environments>
セクションを交換するために管理が、私は取り除くことができません:私は書くことを試みた
<mappers><mapper resource="mailbox/db/map/FileMapper.xml"/> </mappers>
:
sqlSessionFactory.getConfiguration()。addMapper(FileMapper.class);
が、例外があります。
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