John, Thank you very much for pointing me to Twig. I'll play around with it this weekend and get back to you if I have any questions.
Thanks, Shrikrishna On Feb 6, 12:12 am, John Patterson <[email protected]> wrote: > Hi Shrikrishna , > > Im not sure about Objectify but Twig supports storing and retrieving > Polymorphic references. Your example could be persisted out-of-the- > box with no extra configuration. > > Also Twig does handle querying on VehicleType - although you say that > this is not yet a requirement. > > Currently to query across all vehicle types you would need to issue > multiple queries and join them. But this is simple even when your > results are sorted using the support class SortedMergeIterator. > > BTW, to fully support polymorphic queries is actually quite a simple > extension that I just haven't had the need for yet and so haven't > written. If you were willing to hack a patch I would be happy to give > you some pointers where to start. > > http://code.google.com/p/twig-persist/ > > John > > On 5 Feb 2010, at 18:45, Shrikrishna Shrin wrote: > > > > > Hi, > > > I am developing an application that requires persisting of different > > object categories that are all subclasses of a specific type. Say I > > have a super class Vehicle and two subclasses Car extends Vehicle > > and Ship extends Vehicle. Ideally what I would like to do is to be > > able to query across all Vehicle objects as well as Car and Ship > > objects separately. > > > It looks like the PolyModel class from the app engine Python API > > does this > > (http://code.google.com/appengine/docs/python/datastore/polymodelclass... > > orhttp://code.google.com/appengine/articles/polymodel.html) > > > However, from the following thread it seems like this is not (yet?) > > supported in the Java API: > >http://groups.google.com/group/google-appengine-java/browse_thread/th... > > > To get around this *limitation* I do something like this > > > class Vehicle { > > > String id; > > ............ > > ............ > > > String vehicleType; // indicates what the vehicle type is, eg: > > Car / Ship. > > Text vehicleData; // a blob of text that is a String > > representation of a JSONObject that contains info specific to a > > vehicle type. > > } > > > I am aware that one immediate flaw in my approach is that you cannot > > query by vehicleType specific fields contained in the vehicleData > > blob. This is *NOT* important for my current app (I only need to > > query across vehicle properties but the view on the client side > > depends on the vehicleType). However, I am interested in knowing if > > it is possible to get around this? > > > The front end for my app uses GWT and basically what it does is it > > gets Vehicle objects via RPC and triggers the corresponding > > presenter & view based on the vehicleType. Each presenter in turn > > knows what to do with the corresponding vehicleData JSON blob. > > > Am currently using Objectify (http://code.google.com/p/objectify-appengine/ > > ) for persistence but there doesn't seem to be any built-in support > > for polymorphism as yet. > > > Thanks, > > > Krishna > > > -- > > 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 > > athttp://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.
