【问题标题】:google app engine - Portion of expression could not be parsed谷歌应用引擎 - 无法解析部分表达式
【发布时间】:2014-09-23 05:06:22
【问题描述】:

我想从 Google App Engine 数据存储中获取除一个特定类别之外的类别数据。

为此,我的 ApiMethod 中的查询如下所示:

Query query = mgr
                .createQuery("Select c from IconCategoryMaster c where c.categoryIsPurchased = :isPurchased and c.categoryName != :catName order by c.categoryName,c.categoryType desc");
        query.setParameter("isPurchased", true);
        query.setParameter("catName", "TemplateICons");

当我尝试执行此 API 时,我收到如下异常:

com.google.api.server.spi.SystemService invokeServiceMethod: Portion of expression could not be parsed: != :catName
Portion of expression could not be parsed: != :catName
org.datanucleus.store.query.QueryCompilerSyntaxException: Portion of expression could not be parsed: != :catName
    at org.datanucleus.query.compiler.JPQLParser.parse(JPQLParser.java:77)
    at org.datanucleus.query.compiler.JavaQueryCompiler.compileFilter(JavaQueryCompiler.java:466)
    at org.datanucleus.query.compiler.JPQLCompiler.compile(JPQLCompiler.java:81)
    at org.datanucleus.store.query.AbstractJPQLQuery.compileInternal(AbstractJPQLQuery.java:271)
    at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:799)
    at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:437)
    at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:57)
    at com.wallpapermaker.keepcalm.IconMasterEndpoint.getAllIcons(IconMasterEndpoint.java:228)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:45)
    at com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:359)
    at com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:160)
    at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:118)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:438)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:445)
    at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:220)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:309)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:301)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:442)
    at java.lang.Thread.run(Thread.java:724)

谁能帮助我解决为什么我会遇到这种异常以及我哪里出错了? 谢谢。

【问题讨论】:

    标签: android google-app-engine jpa google-cloud-datastore


    【解决方案1】:

    != 是支持的查询语言中的运算符吗?我看到<> 可能在那里,至少根据source of the parser,但我不知道!= 是否存在。

    当我阅读 JPQL 参考文档中的 list of operators 时,我没有在其中看到 !=

    【讨论】:

    • 非常感谢您的快速回复。你是对的。我和接线员搞错了。用<> 替换!= 效果很好,我得到了预期的结果。再次感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多