我的jpa查询是
@Query(value="SELECT area FROM hoardings WHERE area LIKE %?1% GROUP by area order by instr(area, ?1)", nativeQuery=true)
public List<String> searchByArea(String area);
它没有提供与我的SQL查询相同的顺序
SELECT area FROM 'hoardings' WHERE 'area' LIKE '%n%' GROUP by area order by instr(area, 'n')
我认为JPA原生查询不支持通过参数传递的顺序。有没有其他方法可以解决这个问题。感谢
答案 0 :(得分:2)
更改为 -
@Query(value="SELECT area FROM hoardings WHERE area LIKE %:area% GROUP by area order by instr(area, :area)", nativeQuery=true)
public List<String> searchByArea(String area);