Closed GoogleCodeExporter closed 9 years ago
Attached in patch form
Original comment by michael....@gmail.com
on 20 Apr 2010 at 1:50
Attachments:
I don't understand how "geocellsP.contains(geocells)" or
"geocells.contains(geocellsP)" is supposed to work.
geocells may be e.g. ["a", "ab", "abc", ...]
geocellsP may be e.g. ["abc","abd", ...]
"abc" is found in the geocells, but "abd" will not be.
i.e. the geocells does not contain the geocellsP
Neither the geocellsP contains the geocells.
Also, java.util.List does not have such as method as boolean contains(List list)
It has boolean contains(Object object), where the object is the member of the
List
What we needed is: e.g.
boolean containsAtLeastOneOf(List list)
but the java.util.List has no such a method, nor such is allowed in the JDO QL
API.
Original comment by takayama...@gmail.com
on 1 Jun 2010 at 5:40
Solution: (something like below)
Query query = pm.newQuery(<T>.class);
query.setFilter("geocells.contains(cellName)");
query.declareParameters("String cellName");
List<T> allObjects = new List<T>();
List<T> objects = null;
for (String cellName: cellList)
{
objects = (List<T>) query.execute(cellName);
if (allObjects.size() + objects.size() > maxObjects) break;
allObjects.addAll(objects);
}
Original comment by takayama...@gmail.com
on 1 Jun 2010 at 12:33
This original code is working well (both ways are ok):
Query query = pm.newQuery(entityClass, baseQuery.getBaseQuery() + and +
"geocellsP.contains(geocells)");
Explanation:
geocells are the cells containing the entity ["a", "ab", "abc", ...]
geocellsP are the cells where we search ["abc","abd", ...]
So we want that one element of geocells is in the list geocellsP.
For instance, above, "abc" from geocells is in geocellsP so the entity matches.
"contains" operator works like this (see
http://code.google.com/appengine/docs/java/datastore/queriesandindexes.html#Intr
oducing_Queries):
Query query = pm.newQuery(Employee.class,
":p.contains(lastName)");
query.execute(Arrays.asList("Smith", "Jones"));
So, lastName must be in the list ("Smith", "Jones").
But instead of a string (lastName), we can use a list (in our case "geocells");
and when we use a list, it will check if ONE of its element is matching.
Original comment by alexandr...@gmail.com
on 10 Nov 2010 at 9:24
My mistake, you're right, this way throws exception (see issue 18).
I've reversed the way.
Available on 0.0.4.
Original comment by alexandr...@gmail.com
on 11 Nov 2010 at 6:32
Original issue reported on code.google.com by
nitin.na@gmail.com
on 17 Apr 2010 at 3:02