我正在尝试运行下面的代码但是我收到了错误。
public MdFeedHandOff getFeedByHandOff(Integer handoff, Integer csiID){
logger.error("*************getFeedByHandOff(): handoff value is "+handoff);
String hql = "FROM MdFeedHandOff a WHERE a.handoff = :handoff and a.active in ('A','I') and to_char(a.handoff) like :csiID%";
Map<String, Object> param = new HashMap<String, Object>();
param.put("handoff", handoff);
List<MdFeedHandOff> batchJobList = searchForList(hql, param);
return batchJobList.isEmpty()?null:batchJobList.get(0);
}
我想在hql中使用%运算符。请帮助我。 我也尝试过以下行,但它不起作用。
String hql = "FROM MdFeedHandOff a WHERE a.handoff = :handoff and a.active in ('A','I') and to_char(a.handoff) like :csiID" + "%";
答案 0 :(得分:2)
您应该在查询中添加:csid
参数名称,并在您设置的参数中添加%通配符。你似乎也没有在参数图中设置csid。
<强>查询强>:
FROM MdFeedHandOff a WHERE a.handoff = :handoff
and a.active in ('A','I') and to_char(a.handoff) like :csiID";
<强> PARAMS 强>:
Map<String, Object> param = new HashMap<String, Object>();
param.put("handoff", handoff);
param.put("csiID", csiId.toString()+"%");