Elie
Elie

Reputation: 13853

Hibernate Detached Criteria

I have a DetachedCriteria which I am using to search a table based on a name field. I want to make the search case-insensitive, and am wondering if there is a way to do this without using HQL. Something like:

private void searchByFullName(DetachedCriteria criteria, String searchCriteria) {
    criteria.add(Restrictions.like("fullName", "%" + searchCriteria.toUpperCase() + "%"));
    criteria.addOrder(Order.asc("fullName"));
}

But I want to make sure that it will ignore the case when it does the search, so the SQL it generates should look something like:

SELECT * FROM PEOPLE WHERE ? LIKE toUpper(FULL_NAME);

Upvotes: 0

Views: 4496

Answers (1)

Related Questions