I have a class with an enum as instance variable:
public enum Races {
Human, Elf, Orc, Troll
}
@PersistenceCapable(detachable="true")
public class Crafter {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private Races race;
}
I have been able to store and retrieve instances of that class, this is not the problem.
The problem comes when I want to query on, let's say, all the orcs and troll.
Races[] races = new Races[] { Races.Orc, Races.Troll, };
Query query = manager.newQuery(Crafter.class);
query.setFilter(":raceParam.contains(race)");
List<Crafter> crafters = (List<Crafter>) query.execute(Arrays.asList(races));
It doesn't work, I get:
Caused by: java.lang.IllegalArgumentException: race: ca.forklabs.wowtradeskills.web.shared.Races is not a supported property type.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:184)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:149)
at com.google.appengine.api.datastore.Query$FilterPredicate.<init>(Query.java:574)
at com.google.appengine.api.datastore.Query.addFilter(Query.java:260)
at org.datanucleus.store.appengine.query.DatastoreQuery.addLeftPrimaryExpression(DatastoreQuery.java:1343)
...
How does one do IN queries using JDO with the Google App Engine?
Some references: