以下查询在sql developoer中执行时返回单个结果,但在调用
时返回空列表List failedTxnList = getJdbcTemplate().queryForList(query, params);
并且params的值是[IM1691,VSIB01,1 / 4 / 2017,25 / 4/2017]。请帮我在这里找到问题。
select a.echeque_no,a.oid,a.echeque_date,d.name im_name,c.name vendor_name,a.corp_ref_no,b.hundi_date,a.echeque_amount,b.reversal_date,
a.status_description
from sbicorp_echeque_master a, sbi_gvf_vendor_txn_history b,sbi_gvf_vendor_master c, sbi_gvf_im_master d
where a.debit_status = 'ERR.'
and LTRIM(RTRIM(a.corporate_id))= 'IM1691'
and LTRIM(RTRIM(a.businessline_id)) = 'VSIB01'
and trunc(a.echeque_date) BETWEEN TO_DATE ('1/4/2017', 'dd/mm/yyyy') AND TO_DATE ('25/4/2017', 'dd/mm/yyyy')
and a.corporate_id=d.im_code and a.businessline_id = c.vendor_code
and b.txn_type= 'Original Debit'
and a.echeque_no = b.reference_no
and substr(a.echeque_no,0,2) in ('CE','CR','CN','CZ')
order by echeque_date desc -- CE01573281
答案 0 :(得分:0)
我唯一能看到的是
trunc(a.echeque_date) BETWEEN TO_DATE ('1/4/2017', 'dd/mm/yyyy') AND TO_DATE ('25/4/2017', 'dd/mm/yyyy')
尝试更改日期字符串以反映所需的格式
TO_DATE ('01/04/2017', 'dd/mm/yyyy') AND TO_DATE ('25/04/2017', 'dd/mm/yyyy')
答案 1 :(得分:0)
您要获取的List必须是某种类型,并且必须实现rowMapper。 rowMapper告诉spring哪个列映射到哪个对象。
下面提到一个例子。 圆模型类:字段是数据库中的列。
public class Circle {
private int id;
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Circle(String name) {
super();
this.name = name;
}
public Circle(int id, String name) {
super();
this.id = id;
this.name = name;
}
}
为spring定义一行Mapper,将数据库列映射到Circle对象
public static final class CircleMapper implements RowMapper<Circle> {
public Circle mapRow(ResultSet resultSet, int arg1) throws SQLException {
return new Circle(resultSet.getInt("id"),resultSet.getString("name"));
}
}
在Your Service类中调用该对象。
Circle circle = jdbcTemplate.queryForObject("SELECT * from circle where id = ?", new Object [] {id}, new CircleMapper());
对于您的情况,创建一个包含数据库列的模型类。 创建一个映射器类,然后执行。