App Engine - Query using class member as parameter
I have a simple class matching the details below:
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class SimpleCategory implements Serializable{
...
public static enum type{
Course,
Category,
Cuisine
}
@Persistent
public type t;
...
}
I am trying to query all SimpleCategory objects of the same type.
public SimpleCategory[] getCategories(SimpleCategory.type type) {
PersistenceManager pm = PMF.get().getPersistenceManager();
try{
Query q = pm.newQuery(SimpleCategory.class);
q.setFilter("t == categoryType");
q.declareParameters("SimpleCategory.type categoryType");
List<SimpleCategory> cats = (List<SimpleCategory>) q.execute(type);
...
}
This results in a ClassNotResolvedException for SimpleCategory.type. The hits shown by google that I have found so far recommend:
- Use query.declareImports to specify the ieql.declareImports class ("com.test.zach.SimpleCategory.type");
- Specify the full name of SimpleCategory in declareParameters
None of these suggestions worked. By removing the .type and recompiling, I can check that declareParameters can see SimpleCategory just fine, it just can't see SimpleCategory.type, even though the rest of the method is fully visible to it.
What am I missing?
+2
a source to share
2 answers