使用MySQL全文索引Match Against+Pageable查询时参数越界求助
Spring Data JPA原生查询结合MySQL全文索引与Pageable时出现参数索引越界错误
我正在尝试在Spring Data JPA中使用MySQL全文索引的MATCH AGAINST语法,结合Pageable实现分页查询。为了解决旧版本Spring Boot(1.5.4.RELEASE)中原生查询countQuery不生效的问题,我将Spring Boot版本升级到了2.0.0m7,对应的Spring Data JPA版本为2.0.2.RELEASE。目前部分问题已解决,但遇到了如下错误:
javax.servlet.ServletException: org.springframework.orm.jpa.JpaSystemException: could not execute query; nested exception is org.hibernate.exception.GenericJDBCException: could not execute query ... Caused by: java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1)
我的Repository方法代码如下:
@Query( value = "SELECT Distinct u.* " + "FROM user AS u " + "WHERE MATCH(u.name, u.email) against(:filterValue) " + "ORDER BY u.id \n#pageable\n#", countQuery = "SELECT count(Distinct u.id) " + "FROM user AS u " + "WHERE MATCH(u.name, u.email) against(:filterValue) " + "ORDER BY u.id \n#pageable\n#", nativeQuery = true) Page<User> foo(@Param("filterValue") String filterValue, Pageable pageable);
我尝试过把pageable也显式设置为参数,但仍然出现相同的参数索引越界错误,求各位大佬给些解决思路?
内容的提问来源于stack exchange,提问作者j2sb
相关产品推荐
相关产品推荐

