Spring2.5中的BeanPropertyRowMapper
程序员文章站
2022-04-19 21:34:22
...
例如:
public List<AutoProject> searchAutoProject(Integer status) {
String sql = "SELECT * FROM auto_report_project WHERE status = ${status}";
sql = sql.replace("${status}", status + "");
try {
return getJdbcTemplate().query(sql, new BeanPropertyRowMapper(AutoProject.class));
} catch (DataAccessException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
其中,query方法里面的sql语句,需要一个BeanPropertyRowMapper这样一个类去对应自动映射
转载于:https://my.oschina.net/u/1163293/blog/170752