max wrote:
what you are showing is Hibernate's Criteria API - not HQL.
Look at HQL if you want to build up strings instead (but please use parameters on your query instead of 100% string building since its safer (avoid sql injection))
btw.
add(Expression.like("foo", text)) will also do the trick.
Ah, thanks, that clears some stuff up. I'm trying to absorb all this plus Spring, and I missed that distinction along the way. I gather these two are distinct from Hibernate's QBE, as well.
I also realized how simple what I wanted to do is - just put the %'s in the string when doing the set, like so: setString("namedParm", "%" + text + "%"). It always seems simple when you know the answer...
I wanted to avoid the add(), Expression.or() and Expression.like() methods if possible, since I'm most likely doing or's for the dynamic portions of query and it quickly becomes unwieldy to have the nested like()'s inside the the or()'s, inside yet another or(), if you know what I mean.
Thanks again.