使用hql使用order by子句出现异常和数据异常的解决办法org.hibernate.hql.internal.ast.QuerySyntaxException
2014-07-15 10:27
676 查看
org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
今天合作开发一个小型电影推荐系统的时候发现一个问题,我负责编写电影评论部分,在从数据库返回list时,我的list应该是可以排序的,普通评论会按照time属性进行排序,所以在检索的时候,我的hql语句是这样的(orderby子句放在后边)
String hql = "from Comment comment where comment.movieid = "+ movieid + " order by comment.time desc";
这样是对的,但是我开始的时候hql语句是下边这样的
String hql = "from Comment comment order by comment.time desc where comment.movieid = "+ movieid;
请忽略一些博客编写可能产生的空格问题,我在写的时候把order by子句放在了where前边,于是乎console就抛出了异常,还有一个一起开发的同学,也是吧orderby子句放在前边,他没有出现异常,但是数据提取是错的,至于原因不太清楚,今天问下实习部门领导,晚点会有更新。
ps:超级鄙视博客里随意粘贴复制的人,负点责任好吗!
相关文章推荐
- myeclipse 使用weblogic10启动hibernate项目时出现ClassNotFoundException: org.hibernate.hql.ast.HqlToken异常的解决办法
- jpa或bernate使用原生sql进行关联查询org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join
- org.hibernate.hql.ast.QuerySyntaxException: unexpected token 异常解决
- 异常积累:org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token:
- 异常收集-org.hibernate.hql.internal.ast.QuerySyntaxException: activityinfo is not mapped
- org.hibernate.hql.internal.ast.QuerySyntaxException: USER is not mapped 报错解决
- 出现org.hibernate.hql.internal.ast.QuerySyntaxException: goodsinfo is not mapped [from goodsinfo错误
- Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: table is not Mapped问题解决
- 每日一得-org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!错误解决办法
- 使用hibernate的hql语句做查询报错 org.hibernate.hql.internal.ast.QuerySyntaxException: user is not mapped
- Caused by: org.hibernate.hql.ast.QuerySyntaxException: TkltEmpQuitProcess is not mapped. (SSH项目中出现的映射问题)
- org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 3解决方法
- org.hibernate.hql.internal.ast.QuerySyntaxException: Exam is not mapped
- Hibernate org.hibernate.hql.internal.ast.QuerySyntaxException: tb_supplier is not mapp
- org.hibernate.hql.internal.ast.QuerySyntaxException: Admin is not mapped [from Admin where username=
- org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class XXX解决
- org.hibernate.hql.internal.ast.QuerySyntaxException: OrderRecordMonitor is not mapped
- org.hibernate.QueryException:ClassNotFoundException:org.hibernate.hql.ast.HqlToken错误之解决办法
- org.hibernate.hql.internal.ast.QuerySyntaxException: XXXX is not mapped [from XXXX]
- org.hibernate.hql.ast.QuerySyntaxException: **** is not mapped 异常总结