/** * 查询所有的car信息,但是启用了驼峰命名自动映射机制 */ List<Car> selectAllByMapUnderscoreToCamelCase();
<select id="selectAllByMapUnderscoreToCamelCase" resultType="car"> select * from t_car </select>
@Test public void testSelectAllByMapUnderscoreToCamelCase(){ SqlSession sqlSession = SqlSessionUtil.openSession(); CarMapper mapper = sqlSession.getMapper(CarMapper.class); List<Car> cars = mapper.selectAllByMapUnderscoreToCamelCase(); for (Car car : cars) { System.out.println(car); sqlSession.close(); } }
Car{id=93, carNum='3333', brand='大众朗逸', guidePrice=12.0, produceTime='2020-11-11', carType='燃油车'}
Car{id=94, carNum='1111', brand='比亚迪汉', guidePrice=10.0, produceTime='2020-11-11', carType='电车'}
Car{id=95, carNum='3333', brand='大众朗逸', guidePrice=12.0, produceTime='2020-11-11', carType='燃油车'}
Car{id=96, carNum='3333', brand='大众朗逸', guidePrice=12.0, produceTime='2020-11-11', carType='燃油车'}
Car{id=97, carNum='1111', brand='比亚迪汉', guidePrice=10.0, produceTime='2020-11-11', carType='电车'}
Car{id=98, carNum='9991', brand='凯美瑞', guidePrice=30.0, produceTime='2020-11-11', carType='燃油车'}
Car{id=99, carNum='9991', brand='凯美瑞', guidePrice=30.0, produceTime='2020-11-11', carType='燃油车'}
Car{id=100, carNum='1111', brand='比亚迪汉', guidePrice=10.0, produceTime='2020-11-11', carType='电车'}