Case-insensitive search using Hibernate

前端 未结 9 1301
长情又很酷
长情又很酷 2021-01-30 16:13

I\'m using Hibernate for ORM of my Java app to an Oracle database (not that the database vendor matters, we may switch to another database one day), and I want to retrieve objec

9条回答
  •  没有蜡笔的小新
    2021-01-30 16:53

    For the simple case you describe, look at Restrictions.ilike(), which does a case-insensitive search.

    Criteria crit = session.createCriteria(Person.class);
    crit.add(Restrictions.ilike('town', '%fran%');
    List results = crit.list();
    

提交回复
热议问题