不正确的结果SetColumnCount异常:列计数不正确:预期 1,实际 38
2022-09-01 21:41:06
我正在使用从数据库中检索Bean。这是我的方法:JdbcTemplate
public List<trackerv3Livedata> getTrackerData() {
return List<trackerv3Livedata> live = (List<trackerv3Livedata>) jdbcTemplate.queryForList("select * from mmitrackerv3_livedata where accountid =?",new Object[]{aid}, trackerv3Livedata.class);
}
Trackerv3Livedata豆结构如下:
public class trackerv3Livedata implements Serializable {
private static final long serialVersionUID = 2409168269491619888L;
private int deviceid;
private Long timestamp;
private Mmitrackerv3Device mmitrackerv3Device;
private Mmitrackerv3Account mmitrackerv3Account;
private double latitude;
private double longitude;
private Double altitude;
private Double speedkph;
private Double heading;
private Double gpssignal;
private Integer geozoneid;
private Double distancekm;
private Double gsmsignal;
private Double mainpower;
private Integer laststatustime;
private Double internalbattry;
private Double temperature;
private Short dinput1;
private Short dinput2;
private Short dinput3;
private Short dinput4;
private Short dinput5;
private Short dinput6;
private Short dinput7;
private Short dinput8;
private Short ainput1;
private Short ainput2;
private Short ainput3;
private Short ainput4;
private Short doutput1;
private Short doutput2;
private Short doutput3;
private Short doutput4;
/* There are Some Getter And Setter Method With Constructor */
}
在我的场景中,完全有可能不会在我的查询上命中,所以我的问题是我如何绕过以下错误消息。
org.springframework.jdbc.IncorrectResultSetColumnCountException: Incorrect column count: expected 1, actual 38
在我看来,我应该只取回一个 null,而不是抛出一个异常。我该如何解决这个问题?提前致谢。