It's actually much simpler than you realize.  Assuming that your List<Long>
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 filter.

Jeff

On Tue, Jul 19, 2011 at 5:28 PM, keyvez <[email protected]> wrote:

> 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
> 1    5
> 2    1, 4
> 3    1
> 4    1, 2
> 5    1
>
> I would like to find out who are user 1's friends so the query would be
> something like this
>
> SELECT * FROM User WHERE friends.contains(1)
>
> the IN version looks like this
>
> SELECT * FROM User WHERE friends IN (1)
>
> which would return id=3 as a result but it is wrong, I am expecting to see
> id=2,3,4 be returned in the result set. Because they are all friends with
> one.
>
> Also I HAVE to do this through the low level datastore API to utilize the
> cursor feature.
>
> Thanks,
> Gaurav
>
> --
> 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/-/XV-oATd4fjUJ.
>
> 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.
>

-- 
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.

Reply via email to