获取NoViableAltException:意外令牌:WITH with JPA

时间:2017-06-15 12:03:39

标签: java postgresql hibernate jpa dropwizard

我在上一个问题中使用了@klin给出的solution,如下所示。

with given_values (fingerprint, last_fetched) as (
values
    ('a', '2017-01-01'::date),
    ('b', '2017-02-01')
)

select * 
from tracks t
join given_values v
on t.audio_fingerprint = v.fingerprint
and t.modified_date > v.last_fetched;

我正在使用JPA和Hibernate与Dropwizard。我有像这样的实体层次结构。

  • Track可以有一个或多个
    • 结构
    • CueMarker
    • 过渡
    • 类型

想要加载Track及其子实体数据,为此,我尝试了NamedQuery / NamedNativeQuery但是它给了我像这样的令牌错误。

web_1               | ERROR [2017-06-14 19:30:31,274] org.hibernate.hql.internal.ast.ErrorCounter: line 1:1: unexpected token: WITH
web_1               | ERROR [2017-06-14 19:30:31,288] org.hibernate.hql.internal.ast.ErrorCounter: line 1:1: unexpected token: WITH
web_1               | ! antlr.NoViableAltException: unexpected token: WITH
web_1               | ! at org.hibernate.hql.internal.antlr.HqlBaseParser.statement(HqlBaseParser.java:191) ~[app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:295) ~[app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:203) ~[app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) ~[app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]
web_1               | ! at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1800) [app-server-0.0.2-SNAPSHOT.jar:0.0.2-SNAPSHOT]

由于

0 个答案:

没有答案