Named Query with like in where clause
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 + "%");
You can also use CONCAT function
@NamedQuery(name = "Place.getPlaceForCityAndCountryName",
query = "SELECT p FROM Place p WHERE " +
"lower(p.city) like CONCAT(:city,'%')");