Almacén de datos GAE / J: cómo crear una consulta IN con JDO

I am trying to query a collection of entities by its key in the Google App Engine datastore. This is the query I am trying to execute with no success:

Query query = pm.newQuery(Fix.class);
query.setFilter("__key__ IN param");
query.declareParameters(" param");
query.execute(list); // list is an array of keys

Y el error que obtengo es:

javax.jdo.JDOUserException: Portion of expression could not be parsed: IN param

Is it possible to use build an IN query with JDO or the low level API that finds entities by key?

preguntado el 09 de enero de 11 a las 12:01

2 Respuestas

I think you might be confusing the JDO and JPA syntax: see examples on este página


select from Person where
    favoriteFood IN ('cheeseburger', 'pizza', 'fried chicken')
    order by favoriteFood, age


Query q = pm.newQuery(
    "select from Person where :p1.contains(favoriteFood) order by favoriteFood, age");
q.execute(Arrays.asList("cheeseburger", "pizza", "fried chicken"));

Respondido el 09 de enero de 11 a las 21:01

Have you tried examples from consulta en esta página? Algo como:

query.addFilter("__key__", Query.FilterOperator.IN, param);

Tenga en cuenta que param should be a list.

Respondido el 09 de enero de 11 a las 15:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.