HQL like operator for case insensitive search

后端 未结 2 626
日久生厌
日久生厌 2021-02-05 04:08

I am implementing an autocomplete functionality using Jquery, when I type the name, it fetches the record from the db, The records stored in db are mixture of capital & smal

2条回答
  •  一个人的身影
    2021-02-05 04:55

    A good solution is:

    List resultList = null;
    Query query = session.createQuery("from DataOrganization dataOrg where lower(dataOrg.poolName) like :poolName");
    query.setParameter("poolName", '%'+poolName.toLowerCase()+'%');
    resultList =  query.list();
    

    So you protect your code from SQL injection

提交回复
热议问题