我在下面的行中收到此错误
User ret=(User)query.execute(username.toString());
query.execute()
是否只能投放到列表<> ?
java.lang.ClassCastException: com.google.appengine.datanucleus.query.StreamingQueryResult cannot be cast to com.lionpaw.User
at com.lionpaw.UserJDOWrapper.getUserByUsername(UserJDOWrapper.java:33)
at com.lionpaw.LionPawServlet.doGet(LionPawServlet.java:21)
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)
答案 0 :(得分:0)
执行JDO查询将返回适合传入的查询的类型。如果是候选类型的查询,则返回List。您没有提到您的查询,因此无法进一步回答。阅读JDO规范和任何体面的JDO文档,例如http://www.datanucleus.org/products/accessplatform/jdo/jdoql.html#result