public void selectById() {
SqlSession sqlSession = build.openSession();
SysuserMapper mapper = sqlSession.getMapper(SysuserMapper.class);
mapper.selectById(2);
//清空一级缓存,下面会查询两次
sqlSession.clearCache();
mapper.selectById(2);
}
sqlsession是一级缓存,默认开启
sqlsessionFactory默认是关闭的,需要在mybatis的配置文件和sql映射文件中添加配置
在官网中可以看详细配置