spring jdbcTemplate query 返回值为null


spring jdbcTemplate query 返回值为null

今天使用以下方法从数据库中查询数据,返回列表

public List<BookBean> getBooks(){
		String sql = "select * from books where inventory > 0 order by title";
		List<BookBean> books = jdbcTemplate.query(sql, new BeanPropertyRowMapper<BookBean>(BookBean.class));
        return books;
}

但是打印出结果时发现都是null,查找了下原因,主要有以下几点

  1. bean类中没有setter方法
  2. bean类中的字段与数据库中表的字段没有对应


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM