本章讲解QueryRunner开启驼峰映射
话不多说。直接上代码
public static List queryList(String sql, Class clazz) {
Connection connection = getConnection();
QueryRunner queryRunner = new QueryRunner();
// 开启驼峰映射
BeanProcessor processor = new GenerousBeanProcessor();
RowProcessor rowProcessor = new BasicRowProcessor(processor);
List<Object> queryList = null;
try {
queryList = queryRunner.query(connection, sql, new BeanListHandler<Object>(clazz, rowProcessor));
} catch (SQLException throwables) {
throwables.printStackTrace();
}
return queryList;
}