org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on near line 1解决方案

来源:互联网 发布:天窗玻璃 知乎 编辑:程序博客网 时间:2024/05/22 12:50

文章摘自:http://blog.csdn.net/yangwawa19870921/article/details/7553181

 

在编写HQL时,可能会出现这种代码:

Java代码  收藏代码
  1. select a.name,b.age from TableA a left join TableB b on a.id=b.id  

 如果这是HQL,那么这段代码就是错误的,因为HQL不支持ON这个字符,如果要做关联关系就必须将On改为where:

Java代码  收藏代码
  1. select a.name,b.age from TableA a left join TableB b where a.id=b.id