Arun
Arun

Reputation: 3680

Hiberate : HQL Case Insensitive search

My requirement is to do a search in database based on a string.

That particular string might be stored in uppercase, in database.

So, I will have to do a case-insensitive search through HQL

My current HQL is

String query = "from OrganizationContent where orgUrl=:url";
        Map<String,Object> parameterMap = new HashMap<String,Object>();
        parameterMap.put("url", organizationUrlInput.toLowerCase());

Only ".toLowerCase" I can do from java end. Now I need hibernate to fetch the data by doing a case-insensitive search.

Appreciate your help on this friends

Upvotes: 4

Views: 10386

Answers (1)

JB Nizet
JB Nizet

Reputation: 691735

From the documentation:

Expressions used in the where clause include the following:

[...]

Any function or operator defined by EJB-QL 3.0: substring(), trim(), lower(), upper(), length(), locate(), abs(), sqrt(), bit_length(), mod()

from OrganizationContent where lower(orgUrl) = :url

Upvotes: 12

Related Questions