一个东西:
public class MissedCall {
private Timestamp dateTime;
private String callerId;
private Long duration;
public MissedCall(Timestamp dateTime, String callerId, long duration) {
this.dateTime = dateTime
this.callerId = callerId;
this.duration = duration;
}
执行请求的方法:
public class JdbcMissedCallRepositoryImpl implements JdbcMissedCallRepository {
...
private static final RowMapper<MissedCall> ROW_MAPPER = BeanPropertyRowMapper.newInstance(MissedCall.class);
...
public List<MissedCall> getForLastDays() {
...
List<MissedCall> missedCalls = jdbcTemplate.query(query, ROW_MAPPER);
...
}
结果,在列表中我得到一个空的 MissedCall 对象......
如果查询是手动执行的,那么结果是:
+---------------------+-------------+------+
| atm | asrc | adur |
+---------------------+-------------+------+
| 2018-05-02 19:46:21 | 89181112233 | 4 |
+---------------------+-------------+------+
1 row in set (0.00 sec)
他需要什么来匹配这些字段?
明白了。谁在乎 - 对象字段的名称必须与查询输出中的列名称匹配。那些。结果应该是: