Let's take a step back for a moment.  Fundamentally, all these API
layers do is map back and forth between untyped datastore Entity
objects and Java classes.

Let's say the user runs a query that returns an Entity.  Somehow the
framework must figure out what Java class to instantiate and populate
with the contents of that entity.  There are only two possibilities,
either:

 1) The framework must know a-priori how to map Entity kinds to Java classes
 2) The framework must read the full java class information out of the Entity

If you go with #2, you've just created a framework that will break
your datastore when you rename your Java objects.  I'll assume nobody
thinks this is actually a good idea.

So then, how does the framework know how to map an Entity to a class?
You must have *some* sort of registration process.  Let's go through
the options:

 * Registration when the framework first finds the concrete class.

Unfortunately, this won't work because there is no guarantee that the
framework has ever seen the class.  There's no guarantee that the
class is even loaded in the classloader.

 * Registration when the framework loads.

You can do this with a classpath scanner, or a hook into the build
process that generates classes.  Both have downsides.

  * Explicit registration with a method call in your code.

This is the path taken by Objectify.  It is simple, reliable, and
offers the ability to layer a classpath scanner on top.

Jeff

On Thu, Apr 1, 2010 at 12:23 AM, Yasuo Higa <higaya...@gmail.com> wrote:
> Hi Jeff,
>
>> In other words, Twig cannot perform the simple query:
>>
>> Iterable<Object> foo = ofy.query().ancestor(yourobject);
>>
>> If you ever want to support something like this, you will need a
>> registration process.
>>
>> If you ever want to support true polymorphic queries, you will need a
>> registration process.
>>
> Slim3 supports kindless ancestor queries and true polymorphic queries,
> and does not need a registration process.
>
> http://sites.google.com/site/slim3appengine/slim3-datastore/queries-and-indexes/introducing-queries
> http://sites.google.com/site/slim3appengine/slim3-datastore/polymorphic-model
>
> Yasuo Higa
>
> --
> 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 google-appengine-j...@googlegroups.com.
> To unsubscribe from this group, send email to 
> google-appengine-java+unsubscr...@googlegroups.com.
> 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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to