我想在app引擎数据存储上执行IN
查询,因为我将字符串值传递给我的ApiMethod
,但是当我将冗长的数据传递到我的应用引擎后端时,它会抛出异常,如下所示。我不知道我的代码有什么问题。请指导我解决这个问题。
代码:
mgr = getEntityManager();
Query query = mgr.createQuery("select f from UserFeedMaster f where f.isFeedDeleted=:delStatus and f.feedBlobKey in (:feedBlob)");
query.setParameter("feedBlob", feedBlob);
query.setParameter("delStatus", false);
例外:
com.google.api.server.spi.SystemService invokeServiceMethod: Illegal argument
javax.persistence.PersistenceException: Illegal argument
at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(NucleusJPAHelper.java:298)
at org.datanucleus.api.jpa.JPAAdapter.getApiExceptionForNucleusException(JPAAdapter.java:898)
at com.google.appengine.datanucleus.query.QueryExceptionWrappers$2.get(QueryExceptionWrappers.java:72)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterator.hasNext(RuntimeExceptionWrappingIterator.java:103)
at com.google.appengine.datanucleus.query.LazyResult.listIterator(LazyResult.java:107)
at com.google.appengine.datanucleus.query.StreamingQueryResult.iterator(StreamingQueryResult.java:141)
at com.sampleregistrationapp.UserFeedMasterEndpoint.getUserFavouriteFeed(UserFeedMasterEndpoint.java:377)
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:124)
at com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:82)
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:437)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:444)
at com.google.tracing.CurrentContext.runInContext(CurrentContext.java:188)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:308)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:300)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:441)
at java.lang.Thread.run(Thread.java:724)
Caused by: java.lang.IllegalArgumentException: The key path element name is longer than 500 characters.
at com.google.appengine.api.datastore.DatastoreApiHelper.translateError(DatastoreApiHelper.java:39)
at com.google.appengine.api.datastore.DatastoreApiHelper$1.convertException(DatastoreApiHelper.java:76)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:94)
at com.google.appengine.api.utils.FutureWrapper.get(FutureWrapper.java:86)
at com.google.appengine.api.datastore.FutureHelper.getInternal(FutureHelper.java:71)
at com.google.appengine.api.datastore.FutureHelper.quietGet(FutureHelper.java:32)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.peekQueryResultAndIfFirstRecordIndexList(QueryResultsSourceImpl.java:162)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:104)
at com.google.appengine.api.datastore.QueryResultsSourceImpl.loadMoreEntities(QueryResultsSourceImpl.java:91)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.ensureLoaded(QueryResultIteratorImpl.java:142)
at com.google.appengine.api.datastore.QueryResultIteratorImpl.hasNext(QueryResultIteratorImpl.java:62)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterator$1.get(RuntimeExceptionWrappingIterator.java:54)
at com.google.appengine.datanucleus.query.RuntimeExceptionWrappingIterator$1.get(RuntimeExceptionWrappingIterator.java:50)
at com.google.appengine.datanucleus.query.QueryExceptionWrappers$1.get(QueryExceptionWrappers.java:49)
at com.google.appengine.datanucleus.query.QueryExceptionWrappers$2.get(QueryExceptionWrappers.java:68)
答案 0 :(得分:2)
数据存储区中的字符串属性(或键名)不能超过500个字符。这意味着在传递给IN查询的参数列表中包含更长的字符串是没有意义的:您事先知道该字符串不会有任何匹配。
更新
如果将BlobKey存储在实体属性中,请确保将BlobKey作为参数传递,而不是传递该键的String表示形式。如有必要,将字符串转换为BlobKey:
BlobKey blobKey = new BlobKey(blobKeyString);