1
J'essaye d'exécuter le code ci-dessous mais j'obtiens une erreur.Comme% opérateur dans 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);
}
Je veux utiliser comme opérateur% dans hql. Merci de m'aider. J'ai essayé la ligne ci-dessous, mais ça ne marche pas.
String hql = "FROM MdFeedHandOff a WHERE a.handoff = :handoff and a.active in ('A','I') and to_char(a.handoff) like :csiID" + "%";
ce qui est à l'intérieur searchForList? comment créer une requête et définir les paramètres? –
@SuppressWarnings ("non contrôlée") \t Liste publique searchForList (dernière phrase String, carte finale Paramètres) { \t \t retour (liste) getHibernateTemplate(). Execute (nouvelle HibernateCallback() { \t \t \t public Object doInHibernate (session de session) jette HibernateException { \t \t \t \t query = session.createQuery (phrase); \t \t \t \t query.setProperties (paramètres); \t \t \t \t return query.list(); \t \t \t} \t \t}); \t} –