Hibernate4.x 報錯 Space is not allowed after parameter prefix ':'
阿新 • • 發佈:2020-02-22
1.問題描述 hibernate4.0使用原生sql:
1 select rowno,goods_value from 2 (SELECT a.user_id,(@rowno:=@rowno+1) as rowno,a.goods_value FROM n_word_rank a,(select (@rowno:=0)) b ORDER BY a.goods_value desc,a.create_date asc ) t where t.user_id= 'xxx'
執行報錯:org.hibernate.QueryException: Space is not allowed after parameter prefix ':' [select rowno.....................
2.問題解決
將 := 改為 /*'*/:=/*'*/ 問題解決
改後
select rowno,goods_value from 2 (SELECT a.user_id,(@rowno/*'*/:=/*'*/@rowno+1) as rowno,a.goods_value FROM n_word_rank a,(select (@rowno/*'*/:=/*'*/0)) b ORDER BY a.goods_value desc,a.create_date asc ) t where t.user_id= 'xxx'