On Fri, Sep 4, 2009 at 5:08 AM, Corneliu Paul Lupulet <
[email protected]> wrote:
> I noticed that i can make a query like this:
>
> DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
> Query query = new Query("DbContact");
> query.addFilter("__key__", FilterOperator.GREATER_THAN,
> KeyFactory.stringToKey(a_key_string));
>
> And it works. It fetches the correct results.
>
> Yes, you can always filter by __key__.
> Then i also noticed i can do this (locally on my computer; i haven't tested
> this on app-engine yet):
>
> entity.put("__key__", "some value");
> ds.put(entity);
> Using the datastore viewer i can see the object with this property
> (__key__) and the corresponding value i've set.
>
> I'm pretty sure this should generate an exception locally and in
production. If it isn't, please file a bug.
> Then if try a query like this:
> q1.addFilter("__key__", FilterOperator.EQUAL, "some value");
>
> it doesnt' fetch any results!
>
> Right. __key__ always refers to the Key of the entity and there is no
Entity in the datastore with a Key equal to "some value." This is the
correct behavior.
> So can someone explain the mechanism of what is happening over here? :)
>
> One last thing i've noticed:
> If i try the following line in DataViewer --> Query (using GQL):
> SELECT * FROM DbCategory where __key__ > 'a'
>
> I get:
>
> server error(500)
> Server Error
>
> A server error has occurred.
>
> Please file a separate bug for this.
> And also, are there any other "reserved" properties like "__key__" i should
> be aware of, or which are useful for special kinds of queries.?
>
No, that's the only one at the moment.
http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/Entity.html#KEY_RESERVED_PROPERTY
>
> On Fri, Sep 4, 2009 at 2:17 PM, Cornel <[email protected]> wrote:
> >
> > Hello,
> >
> > How can i make a Query using the lowlevel API, similar to this:
> > select * from Entity where key > <certain_key> ?
> >
> > In JDO i would do something like this:
> > select * from Entity where encodedKey > <a_key_string>
> >
> > where encodedKey is my objects' primary key:
> >
> > @PrimaryKey
> > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> > @Extension(vendorName="datanucleus", key="gae.encoded-pk",
> > value="true")
> > private String encodedKey;
>
>
> --
> Corneliu Paul Lupulet
>
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---