hql.ast.QuerySyntaxException:运行查询的意外令牌

时间:2017-01-23 14:34:29

标签: hibernate spring-mvc hql

我有一个基于Spring Web模型 - 视图 - 控制器(MVC)框架的项目。 Spring Web模型 - 视图 - 控制器(MVC)框架的版本是3.2.8。

我有一个运行1个查询的异常

     at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)
Caused By: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: app near line 1, column 106 [ select company.id from com.tdk.iot.domain.Application app where app.androidId is not null app.status in (:status)  join app.firstSignatory.company as company  where company.logo is not null  ]
        at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
        at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
        at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
        at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
        at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:93)

1 个答案:

答案 0 :(得分:1)

您在where子句条件

中缺少and
SELECT company.id 
FROM   com.tdk.iot.domain.application app 
WHERE  app.androidid IS NOT NULL AND app.status IN (:status) 
JOIN   app.firstsignatory.company AS company 
WHERE  company.logo IS NOT NULL