You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:26:54