我正在尝试从我的java应用程序运行一个简单的查询:
SELECT * FROM Schedule where date > DATETIME(2013,11,10)
如果获得以下错误JSON响应:
03-06 14:03:13.730: W/System.err(13272): com.google.api.client.googleapis.json.GoogleJsonResponseException: 503 Service Unavailable
03-06 14:03:13.730: W/System.err(13272): {
03-06 14:03:13.730: W/System.err(13272): "code" : 503,
03-06 14:03:13.730: W/System.err(13272): "errors" : [ {
03-06 14:03:13.730: W/System.err(13272): "domain" : "global",
03-06 14:03:13.730: W/System.err(13272): "message" : "javax.persistence.PersistenceException: Problem with query <SELECT FROM Schedule as Schedule WHERE date > DATETIME(2013,11,10)>: Unsupported method <DATETIME> while parsing expression: InvokeExpression{STATIC.DATETIME(Literal{2013}, Literal{11}, Literal{10})}",
03-06 14:03:13.730: W/System.err(13272): "reason" : "backendError"
03-06 14:03:13.730: W/System.err(13272): } ],
03-06 14:03:13.730: W/System.err(13272): "message" : "javax.persistence.PersistenceException: Problem with query <SELECT FROM Schedule as Schedule WHERE date > DATETIME(2013,11,10)>: Unsupported method <DATETIME> while parsing expression: InvokeExpression{STATIC.DATETIME(Literal{2013}, Literal{11}, Literal{10})}"
03-06 14:03:13.730: W/System.err(13272): }
当我从app引擎网站上的管理控制台运行它时,这个确切的查询工作得很好 'date'是一个DateTime字段,我有一个索引。 在应用程序引擎网站上,该字段如下所示:“2014-04-13 00:00:00”
这是我的代码:
EntityManager mgr = null;
Cursor cursor = null;
List<Schedule> execute = null;
try {
mgr = getEntityManager();
Query query = mgr.createQuery("select from Schedule as Schedule "
+ "where date > DATETIME(2013,11,10)");
if (cursorString != null && cursorString != "") {
cursor = Cursor.fromWebSafeString(cursorString);
query.setHint(JPACursorHelper.CURSOR_HINT, cursor);
}
if (limit != null) {
query.setFirstResult(0);
query.setMaxResults(limit);
}
execute = (List<Schedule>) query.getResultList();
cursor = JPACursorHelper.getCursor(execute);
if (cursor != null)
cursorString = cursor.toWebSafeString();
// Tight loop for fetching all entities from datastore and accomodate
// for lazy fetch.
for (Schedule obj : execute)
;
} finally {
mgr.close();
}
return CollectionResponse.<Schedule> builder().setItems(execute)
.setNextPageToken(cursorString).build();
任何帮助我都非常感激