0

I'm trying to get my @NamedQuery to filter some results (for an autocomplete) and I'm able to compare lower case, but I can't seem to shoehorn a like in there. I'm trying to do something like this:

@NamedQuery(name="customer.by.partial.lower.name", 
            query="from Customer where lower(name) like '%'+lower(:partial)+'%'")

I've tried a lot of different variations:

lower(name) like lower(%:partial%)
lower(name) like %lower(:partial)%

And I've tried every version I can think of, but each one has its own problems. Is there some way to perform a case-insensitive like query in HQL? Please do not suggest I use a Criteria. I need to keep my queries at the top of the class for maintenance reasons.

corsiKa
  • 81,495
  • 25
  • 153
  • 204
  • 2
    The following article may help. http://stackoverflow.com/questions/1341104/parameter-in-like-clause-jpql – neal Mar 05 '16 at 21:53
  • @neal Ah, I searched many different posts but that one didn't come up. It did, however, solve the problem. Thanks! – corsiKa Mar 05 '16 at 22:14

0 Answers0