查询时候想根据分数排序并且添加对应的名词序号,所以mysql语句中出现了(@i:=@i+1),在navicat下可以正常的运行.但是在使用@Query时出现’JPA Space is not allowed after parameter prefix ‘’:’’’错误;

<Excerpt in index | 首页摘要>

<The rest of contents | 余下全文>

@Query注解如下:

1
2
@Query(value = "select (@i:=@i+1)pm from record s,(select @i:=0)t  order by score desc;",nativeQuery = true)

去查资料,解决方案是把:转义 变成//:

1
@Query(value = "select (@i\\:=@i+1)pm from record s,(select @i\\:=0)t  order by score desc;",nativeQuery = true)