谷歌应用引擎 - 无法解析表达的部分

时间:2014-09-23 05:06:23

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

我想从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)

任何人都可以帮我解决这个问题,为什么我会遇到这样的例外以及我哪里出错了? 谢谢。

1 个答案:

答案 0 :(得分:3)

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

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