Issue using date when querying appengine datastore

I am executing this request:

SELECT FROM com.Data WHERE entryDate> DATE ('2010-3-16')

I am getting this error:

org.datanucleus.store.appengine.query.DatastoreQuery $ UnsupportedDatastoreFeatureException: Problem with DATE query ('2010-3-16')>: Unsupported method while parsing expression: InvokeExpression {[null] .DATE (Literal {2010-3-16 })}

The same query works when I use it in the admin console. But it doesn't work for code (java), locally or when deploying. Any ideas?

+2


a source to share


3 answers


Have you tried using datetime? Dates, times, and dates are stored internally as times; perhaps the Java SDK does not implement this automatic casting for you.



+1


a source


I had the same problem

try:



Query query = pm.newQuery("select from com.Data where entryDate > myDate");
query.declareImports("import java.util.Date");
query.declareParameters("Date myDate");
query.execute(now);

      

+1


a source


I suggest storing all your dates as Long and doing the conversion to a static date before doing the query.

+1


a source







All Articles