views:

727

answers:

1

This page describes an 'IN' operator that can be used in GAE Datastore to compare a field against a list of possible matches, not just a single value:

However this is for Python. In Java (App Engine 1.2.5), trying

query.setFilter("someField IN param");

on my javax.jdo.query fires a JDOUserException 'Portion of expression could not be parsed: IN param'.

Is there a way this can be done?

A: 

The Python version of IN is actually implemented in application-level code (which you can examine since it's part of the open-sourced App Engine SDK): essentially, a query with an IN like yours becomes N queries with == (where N == len(param)) and the results of those N queries are merged back as the overall result.

While it's arguably convenient to have this functionality as part of Google-supplied source code, there's really no added value beyond this convenience, and in particular there is no performance advantage wrt just doing it in your own code. So, I'm not surprised that this minor tweak was (at least so far) not added to the Java version...

Alex Martelli