SqlSessionFactory sqlSessionFactory = SqlSessionUtils.getSqlSessionFactory();
SqlSession sqlSession = sqlSessionFactory.openSession();
SqlSession sqlSession2 = sqlSessionFactory.openSession();
UserMapper mapper = sqlSession.getMapper(UserMapper.class);
User userById = mapper.findUserById(42);
System.out.println(userById.hashCode()); //936580213
sqlSession.close();
UserMapper mapper2 = sqlSession2.getMapper(UserMapper.class);
User userById2 = mapper2.findUserById(42);
System.out.println(userById.hashCode()); //936580213
sqlSession2.close();
System.out.println(userById == userById2); //false
命中了没有去查询数据库,拿到的值跟第一次的一样,不过我也跟你一样的结果,应该是又浅克隆了一份,只是多了一份指针引用,成员变量的引用都是同一个地址