Google App Engine Query .addFilter

442 views Asked by At

I've been struggling with queries with Google's datastore and wanted to get some help.

I have a form that saves a double to the datastore. Here is a snippet from the servlet:

String temp = req.getParameter("temp");
message.setProperty("temp", temp);

temp is a string but containes a number with decimal places.

In my JSP code I'm trying to run the query:

query.addFilter("temp",Query.FilterOperator.GREATER_THAN, -0.9);

But it only seems to work if the value (-0.9) is an integer (-1). Also, when I try to use a variable I get an invalid constant error:

query.addFilter("temp",Query.FilterOperator.GREATER_THAN, request.getParameter('mintemp'));

Any help would be appreciated! Thanks!

1

There are 1 answers

0
proppy On BEST ANSWER

Chance are you are setting your property as a String, you should store the property as a Float instead see the documentation for setProperty.

Convert your String to a Float before setting the Entity property:

message.setProperty("temp", Float.parseFloat(temp));