0

我有下面的代码从谷歌应用引擎的数据存储中获取值。

PersistenceManager pm = JDOUtil.get().getPersistenceManager();
Extent extent = pm.getExtent(LeaderBoard.class, true);

Query q = pm.newQuery(extent);
q.setFilter("game =='"+game+"'");
q.setOrdering("time DESC,createdDate DESC");

List<LeaderBoard> leaderBoard = (List<LeaderBoard>) q.execute();
pm.close();

但是当我尝试它给我一个奇怪的错误时,我在下一行不熟悉。

List<LeaderBoard> leaderBoard = (List<LeaderBoard>) q.execute();

下面是堆栈跟踪。这有时会起作用。但它现在不工作。我正在使用谷歌应用引擎和 jdo。

ERROR :java.lang.ClassCastException: org.datanucleus.query.evaluator.memory.InMemoryFailure cannot be cast to java.lang.Comparable
stackTrace  :java.lang.ClassCastException: org.datanucleus.query.evaluator.memory.InMemoryFailure cannot be cast to java.lang.Comparable
    at org.datanucleus.query.QueryUtils$3.compare(QueryUtils.java:1317)
    at java.util.Arrays.mergeSort(Arrays.java:1446)
    at java.util.Arrays.legacyMergeSort(Arrays.java:1356)
    at java.util.Arrays.sort(Arrays.java:1345)
    at org.datanucleus.query.QueryUtils.orderCandidates(QueryUtils.java:1288)
    at org.datanucleus.query.evaluator.JavaQueryEvaluator.ordering(JavaQueryEvaluator.java:471)
    at org.datanucleus.query.evaluator.JavaQueryEvaluator.execute(JavaQueryEvaluator.java:220)
    at com.google.appengine.datanucleus.query.JDOQLQuery.performExecute(JDOQLQuery.java:153)
    at org.datanucleus.store.query.Query.executeQuery(Query.java:1789)
    at org.datanucleus.store.query.Query.executeWithArray(Query.java:1666)
    at org.datanucleus.store.query.Query.execute(Query.java:1639)
    at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:221)
    at com.googlecreativelab.dao.LeaderBoardDAO.isTopScore(LeaderBoardDAO.java:68)
    at com.googlecreativelab.dao.LeaderBoardDAO.saveTopScore(LeaderBoardDAO.java:26)
    at com.googlecreativelab.service.GameDataService.processRequest(GameDataService.java:188)
    at com.googlecreativelab.service.GameDataService.doGet(GameDataService.java:290)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
    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 com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:102)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:35)
    at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
    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 com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:266)
    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 com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:146)
    at com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:447)
    at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:454)
    at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:461)
    at com.google.tracing.TraceContext.runInContext(TraceContext.java:703)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:338)
    at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:330)
    at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:458)
    at com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:251)
    at java.lang.Thread.run(Thread.java:679)

下面是排行榜类

@PersistenceCapable
public class LeaderBoard implements Serializable {

    private static final long serialVersionUID = 3671283388721366564L;
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;
    @Persistent
    private String name;
    @Persistent
    private Integer avatar;
    @Persistent
    private String game;
    @Persistent
    private Integer time;
    @Persistent
    private Date scoredDate;

    //Setter and getters

而且我发现只有在“时间”列中存在相同值并且我试图通过“排序依据”查询对它们进行排序时才会出现错误。例如,在数据存储中,我有两行,“时间”列的值为 955。然后我不能按顺序进行,如果它的 955、966 类似于该订单查询有效。希望我说清楚了:)。这是一个错误还是什么。我传递给游戏的价值是“运行”

4

2 回答 2

0

因此,您启用了内存查询,但它无法评估数据存储区中的所有查询,并且您使用的内存评估器的功能无法满足该查询。大概使用了 GAE JDO 插件的 v2.0.x(如果能实际引用所用软件的版本就好了)。

使用 GAE JDO 插件 v2.1.1(带有 DataNucleus 3.1.x),它具有更完整的内存查询功能。

于 2012-11-15T07:52:42.740 回答
0

解决了这个问题:),问题出在我有“scoredDate”的实体中,我试图按“createdDate”排序。男生问题:)。但是 GAE 仍然没有给出适当的例外。很坏

于 2012-11-15T11:30:04.180 回答