I do know that calling it once works kinda like this. I never use
declarations in my code so I don't know if this works.
query.setFilter( "password == passwordParam && username == usernameParam &&
active == activeParam" );
But I do know setting a filter works like this:
query.setFilter( "password == \"" + passwordParam + "\" && username == \"" +
usernameParam + \" && active == \"" + activeParam + "\"" );
1. numeric types do not need quotes
2. ancestors and other object types are a bit different.
3. to debug, pause on the query object, it looks simliar to sql.
Here is a snippet from one of my query methods I use to get the data for GWT
RPC transport. There are many ways to do it:
public ThingStuffData[] query(ThingStuffDataFilter filter) {
if (filter == null) {
log.severe("ERROR: ThingStuffJdo.query() Set a filter");
return null;
}
String qfilter = filter.getFilter();
System.out.println("ThingStuffJdo.query(): filter: " + qfilter);
// nullify
queryThingStuffJdo = new ArrayList<ThingStuffJdo>();
PersistenceManager pm = sp.getPersistenceManager();
try {
Query q = pm.newQuery("select stuffIdKey from " +
ThingStuffJdo.class.getName());
q.setFilter(qfilter);
q.setRange(filter.getRangeStart(), filter.getRangeFinish());
List<Key> ids = (List<Key>) q.execute();
Iterator<Key> iter = ids.iterator();
while (iter.hasNext()) {
Key key = (Key) iter.next();
queryKey(key);
}
q.closeAll();
} catch (Exception e) {
e.printStackTrace();
log.log(Level.SEVERE, "", e);
} finally {
pm.close();
}
// work in null if need be
if (queryThingStuffJdo == null || queryThingStuffJdo.size() == 0) {
return null;
}
// convert to object array
ThingStuffJdo[] tsj = new ThingStuffJdo[queryThingStuffJdo.size()];
if (queryThingStuffJdo.size() > 0) {
tsj = new ThingStuffJdo[queryThingStuffJdo.size()];
queryThingStuffJdo.toArray(tsj);
}
// convert for transport to client
List<ThingStuffJdo> tjsa_list = Arrays.asList(tsj);
ThingStuffData[] tsd = convert(tjsa_list);
return tsd;
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.