Hello! I would like to bring in discussion a comparison between JDO and the low level API. Google recommends using the low-level API only to framework developers, but JDO seems to inflexible to me.
I've been using JDO for a month now and i've come across some nasty limitations. I will mention a few here: The datastore itself is very flexible: you can have an entity called "SimpleObject" with "property1name" and "propery2name" and another "SimpleObject" with "property1name" and "propery3name"! A low level API query for entities of kind "SimpleObject" will fetch both. In JDO, i simply cannot define two objects with the same name "SimpleObject" and different properties, so i cannot take advantage of this feature that the datastore offers! JDO offers "Owned One-to-Many Relationships" by defining a List of objects that will be persisted as the children of the current object; also one can manipulate these objects by calls to List methods. But what if i want to say "list.get(50.000)" ? How is this implemented? Will it try to bring all 50.000 entities in memory (and fail?!), or will it bring only the 50.000th one? In the latter case, how does it "count" to 50.000, because the low level API doesn't offer support for "limit 1 offset 49.999" (it's above the 1000 limit) Or let's say i need to get the child from that list, that satisfies a certain condition: "get the 5th child that has propertyX='y' "; in pseudo-code something like this: list.get('propertyx', OP_EQUALS, 'y', 5). There is no such thing obviously; i should use a query instead: "select * from SimpleObjectChild where propertyX = 'y' and ancestor is _simpleobjectkey_" which is fine. My question is: since i need to use queries for more complicated issues, why bother with the list declaration :), if i will never use the plain old list.get(i). You might suggest iterating through the list: for (SimpleObjectChild soc: List) { if (soc.properyX.equals(y) { do_something(); } } But isn't this prohibitively inefficient?? If i have a list of 100.000 elements, of which only about 100 have propertyX='y', i could fetch them (very fast) via the query: "select * from SimpleObjectChild where propertyX = 'y' and ancestor is _simpleobjectkey_", then operate on them. Regarding JDO Extent, it's also very inefficient (in my opinion)! See following example: doit() { for (DbContact db : extent) { if (db.getVersion().equals("0.0")) { do_stuff(); db.setVersion("0.2"); } } } If i have a list of 100.000 elements, and have already handled 75.000 of them on previous calls (there is the 30 second limit to a call, not enough time to handle all entities in a call); then, on a successive call, the extent will also "pass" through "version 2.0" entities, wasting time, and maybe even never reaching a "version 1.0" entity within the 30 seconds allowed. Instead i took the following approach: (AdvancedQuery is a simple wrapper made by me, over JDO Query) I am using a query, that always fetches the first 50 (could be any number) unhandled objects so far. It is written in JDO, but can just as easily be written in the low level API. doit() { AdvancedQuery aq = new AdvancedQuery(pm.newQuery (DbRawContact.class)); aq.addFilter("version", "==", "0.1"); if (!firstRun) { aq.addFilter("encodedKey", ">", lastKey); } aq.appendOrdering("encodedKey ascending"); aq.setLimit(50); List <DbRawContact> results = (List<DbRawContact>) aq.execute (); for (DbRawContact db : results) { do_stuff(); db.setVersion("0.2"); lastkey = db.key; } return lastkey; } I am seriously thinking of developing my own framework based on the low-level API to take advantage of it's full power and flexibility. I know what the pros are (power and flexibility), i'm asking are there any cons? :) (besides, perhaps, longer developing time and effort on my behalf) Corneliu --~--~---------~--~----~------------~-------~--~----~ 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-java@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 -~----------~----~----~----~------~----~------~--~---