Named Query with like in where clause

前端 未结 4 1134
无人及你
无人及你 2020-12-29 03:49

Is it possible to have a like in a where clause in a named query? I am trying to do the following but am getting exceptions

@NamedQuery(name = \"Place.getPla         


        
4条回答
  •  孤城傲影
    2020-12-29 04:03

    You can't have the % in the NamedQuery, but you can have it in the value you assign the parameter.

    As in:

    String city = "needle";
    query.setParamter("city", "%" + city + "%");
    

提交回复
热议问题