java - In google-app-engine: How to query all entries after specific date in GQL -
i'm trying run simple query java application:
select * schedule date > datetime(2013,11,10)
if following error json response:
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 query <select schedule schedule 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 query <select schedule schedule 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): }
this exact query works fine when run admin console on app engine website 'date' datetime field , have index it. on app engine website field looks this: "2014-04-13 00:00:00"
here code:
entitymanager mgr = null; cursor cursor = null; list<schedule> execute = null; try { mgr = getentitymanager(); query query = mgr.createquery("select schedule 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 fetching entities datastore , accomodate // lazy fetch. (schedule obj : execute) ; } { mgr.close(); } return collectionresponse.<schedule> builder().setitems(execute) .setnextpagetoken(cursorstring).build();
any me appreciated
Comments
Post a Comment