1
我想運行下面的代碼,但我得到一個錯誤。像在HQL運營商%
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" + "%";
什麼裏面searchForList?如何創建查詢並設置參數? –
@SuppressWarnings( 「未登記」) \t公開名單searchForList(最後字符串的句子,最後地圖<字符串,對象>參數){ \t \t回報(名單)getHibernateTemplate()。執行(新HibernateCallback(){ \t \t \t公共對象doInHibernate(會話會話)拋出HibernateException的{ \t \t \t \t查詢的查詢= session.createQuery(句子); \t \t \t \t query.setProperties(參數); \t \t \t \t return query.list(); \t \t \t} \t \t}); \t} –