[appengine-java] Contains query Low Level datastore

2011-07-19 Thread keyvez
Hi, I need help with doing a query that uses a contains filter operation. The specific use case is that I have to find all users that are have me as a friend. The User class has a ListLong of friends. In JPA I am able to do something like this SELECT FROM User u WHERE

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread Bruno Fuster
select * from User where friends in (200,300,400) On Tue, Jul 19, 2011 at 3:46 PM, keyvez key...@gmail.com wrote: Hi, I need help with doing a query that uses a contains filter operation. The specific use case is that I have to find all users that are have me as a friend. The User class has

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread Bruno Fuster
Use the IN constant http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Query.FilterOperator.html#IN On Tue, Jul 19, 2011 at 3:49 PM, Bruno Fuster brunofus...@gmail.com wrote: select * from User where friends in (200,300,400) On Tue, Jul 19, 2011 at 3:46

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread keyvez
Thanks for your quick response. After looking into the IN operator, it doesn't seem to be what I need. My table looks like this. User table: id friends 15 21, 4 31 41, 2 51 I would like to find out who are user 1's friends so the query would be something like this

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread Jeff Schnitzer
It's actually much simpler than you realize. Assuming that your ListLong is an indexed property named 'friends', you just need to filter entities for 'friends' equal to your id. This is how list indexes work - if you filter on the property, the entity matches if any value in the list matches the

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread Bruno Fuster
just like Jeff said, it will work using a simple equality filter you can find who's friend with 1 *or* 2 using IN (eg: who is friend with 1, 2 *or* 3) if you need to find who's friend with 1 *and* 2, query using 2 equality filters anyway, be careful with lists... if you have 2 friends following

Re: [appengine-java] Contains query Low Level datastore

2011-07-19 Thread keyvez
Thanks Jeff and Bruno, will try that out. -- You received this message because you are subscribed to the Google Groups Google App Engine for Java group. To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine-java/-/0TM8G5toDwYJ. To post to this group, send