mybatis默认支持一级缓存,不需要在配置文件中去配置
只要执行commit()就必须重新在数据库中查询
public void testCache1() throws Exception {
SqlSession sqlSession = sqlSessionFactory.openSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
User user1 = userMapper.findUserById(1);
System.out.println(user1);
User user = new User("dancheng1", "1", new Date(), "沙哈拉沙漠");
user.setId(1);
userMapper.updateUser(user);
sqlSession.commit();
User user2 = userMapper.findUserById(1);
System.out.println(user2);
sqlSession.close();
}
只要执行commit()就必须重新在数据库中查询