views:

251

answers:

3

I'm working on a servlet in Google App Engine. This servlet retrieves the data from the GAE's datastore; everything works fine when querying like "SELECT * FROM...". But when I want to filter it by a certain column, it does not work since the name of the column has a hypen. It is like the following:

Query query = new Query("tableName");
query.addFilter("col-name", Query.FilterOperator.EQUAL, filterValue);

How do I pass the propertyName with a hyphen?

+1  A: 

java only accepts letters and digits the dollar sign "$", or the underscore character "_" like legal identifiers. So i believe that's not posible. Also did't work in python

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/variables.html#naming

Kristian Damian
Thanks for your comment Kristian, but I was talking about the name of the column in the database.
Pablo
A: 

Is the addFilter method correctly enclosing the column name in single quotes? You might want to try adding them yourself. One can filter by things which are not keys in the database in GQL so this might be something that is expected of you.

Clueless
The single quotes do not work, sorry
Pablo
That's too bad. Good luck discovering the source of your problem.
Clueless
+2  A: 

The AppEngine datastore doesn't have rows or columns; it has models and properties.

The Defining Data Classes talks about defining your models; the important thing to note is that the Java rules for identifier names matter, because each property of a model will at some point be turned into a java object with the same name.

You've described this yourself:

if I filter by a column called "field-1", it is kind of I was trying to subtract 1 from every returned value of the column called field

James Polley