As you suggested, I did the following:

     query.setFilter("parentKey == null");

 and it worked. Thank you very much for your suggestion.

Now I have another problem:
When I am querying for the child nodes, I have the following code:

    query.setFilter("parentKey == parentKeyParam");
    Key parentKey = KeyFactory.createKey(File.class.getSimpleName(),
fileId);
    List<File> childFiles = (List<File>)query.execute(parentKey);

 This query is returning all the Files including those files with
parentKey null. What is wrong with this query?


On Dec 30 2009, 3:13 pm, "Ikai L (Google)" <[email protected]> wrote:
> I'm not sure what will happen when you pass this:
>
> (Key) null
>
> As the query parameter. Instead, what happens if you query on "parentKey ==
> null"?
>
>
>
>
>
> On Tue, Dec 29, 2009 at 11:47 AM, dantuluri <[email protected]> wrote:
> > Hi,
>
> >    I have the following code:
>
> > query = pm.newQuery(File.class);
> > query.setFilter("parentKey == parentKeyParam");
> > List<File> storedFiles = (List<File>)query.execute((Key)null);
>
> >   This query is returning all the Files including those with
> > parentKey not null.
>
> >   What is wrong with this query? I am kinda stuck. Please help me.
>
> > Thanks
>
> > On Dec 28, 1:24 pm, "Ikai L (Google)" <[email protected]> wrote:
> > > You should be able to query for a null value, but you will not be able to
> > > query for an empty value. What is the query you are issuing? What is this
> > > returning?
>
> > > On Wed, Dec 23, 2009 at 8:29 AM, dantuluri <[email protected]> wrote:
> > > > I am new GAE and I need some help. Is it possible to query for
> > > > entities with a property value null using GAE JDO query?
>
> > > > I want something like
>
> > > >   "Get me all the Files that don't have a parent"
>
> > > > In regular relational DBs, it can be queried some thing like this:
> > > >    "select * from File where parentKey is null"
>
> > > > I have a class something like this:
>
> > > > public class File {
> > > >     �...@persistent
> > > >     �...@primarykey
> > > >      private Key id;
>
> > > >     �...@persistent
> > > >      String name;
>
> > > >       @Persistent
> > > >       private Key parentKey;
> > > > }
>
> > > > When I am querying for Files that have null parentKey, query returns
> > > > all Files including those with non-null parentKey value. Is this
> > > > possible to do with GAE?
>
> > > > Thanks!
>
> > > > On Dec 22, 1:33 pm, dantuluri <[email protected]> wrote:
> > > > > Hi,
>
> > > > >     I have an entity that has the following structure:
>
> > > > > File  which has Key as primary key and ParentKey that refers to
> > > > > another File which is parent of this File. Example data for this
> > > > > structure looks like this:
>
> > > > > Key: File(2)
> > > > > Name: Inbox
> > > > > parentKey: File(1)
>
> > > > > It is possible that File may not have a parentKey.
>
> > > > > I want to query the DataStore for Files that don't have parent file
> > > > > (parentKey == null). But when I am querying with parentKey == null, I
> > > > > am still getting all Files including those with parentsKeys. How can
> > > > > we do this with JDO query with App Store? I must be missing something
> > > > > basic here.
>
> > > > > Similarly I would like to get the child folders of a given folder
> > > > > (parentKey == File(1)).
>
> > > > > Any help would be appreciated!
>
> > > > > Thanks
>
> > > > --
>
> > > > 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]<google-appengine-java%2B
> > > >  [email protected]><google-appengine-java%2B
> > [email protected]>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-appengine-java?hl=en.
>
> > > --
> > > Ikai Lan
> > > Developer Programs Engineer, Google App Engine
>
> > --
>
> > 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]<google-appengine-java%2B 
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine

--

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