Hibernate4.x 报错 Space is not allowed after parameter prefix ':'
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'