最近在做的项目使用了JDBC Template来操作数据库,自定义了很多DTO类来接受query的结果。突然项目需求多了一个需要求和的结果:
@Override
<span> </span>public List<VipAwardDTO> getAward(int vipLv) {
<span> </span>String sql = "SELECT " + Vips.COLUMN_GIFT_TYPE + ", SUM("
<span> </span>+ Vips.COLUMN_GIFT_CNT + ") FROM " + Vips.TABLE_NAME
<span> </span>+ " WHERE " + Vips.COLUMN_VIP_LV + " <=?" + " GROUP BY "
<span> </span>+ Vips.COLUMN_GIFT_TYPE;
<span> </span>return this.globalMasterJdbcTemplate.query(sql,
<span> </span>new BeanPropertyRowMapper<VipAwardDTO>(VipAwardDTO.class),
<span> </span>vipLv);
<span> </span>}
结果集中怎么都没有sum()的结果。后来