Journal FortKnox's Journal: [Java/Hib3/EJB3] HQL 'like' clauses.... 4
Ugh, I just spent hours of research to find something. I know this only pertains to <5 people that read this, but I wanted it to be available to the rest of the net in case someone else has the same issue:
If you are using a 'like' clause in hql (I use spring's hibernate template), this is wrong:
If you are using a 'like' clause in hql (I use spring's hibernate template), this is wrong:
getHibernateTemplate().find("from Upc upc where upc.upcNumber like '?%'", new Object[]{param});
HQL doesn't like the look of %'s in its queries... so you have to change it to:
getHibernateTemplate().find("from Upc upc where upc.upcNumber like ?", new Object[]{param + "%"});
The error message I got was out in left field:
IndexOutOfBoundsException: Remember that ordinal parameters are 1-based
REALLLL helpful, there.... sheesh...
ibatis (Score:2)
availability (Score:2)
Slashdot journals are not indexed by search engines (well, the ones that obey robots.txt, anyway, which are the ones anybody actually uses (and I expect that any spider that doesn't is quickly IP-banned)).
HQL (Score:2)
jason
PreparedStatement (Score:2)
Wouldn't you be better off just appending the % to whatever string you're passing in instead of force fitting the %?