Hi,
As mentioned in the subject I have HQL-ilike problem.
I do not use Criteria but Query :
Code:
StringBuffer req = new StringBuffer();
req.append("SELECT count(misc)");
req.append(" FROM MiscValueObject AS misc");
req.append(" WHERE lower(misc.name) like lower('%?%')");
Query q = session.createQuery(req.toString());
q.setString(0, name);
//->Ordinal parameter not found
I have tried too :
Code:
req.append(" WHERE lower(misc.name) like lower('%:param%')");
Query q = session.createQuery(req.toString());
q.setString("param", name)
//->"param" not found
Each time, or ? is not found as an ordinal parameter, or "param" is not found too. I have tried many other possibilities but I could not find any way to make it work. Except the very ugly (due to SQL injection):
Code:
req.append(" WHERE lower(misc.name) like lower('%" + param + "%')");
Query q = session.createQuery(req.toString());
q.setString("param", name)
//->prone to SQL Injection
Any Idea to make it work ?
Thanks
Guillaume