Hi, I would join Steve in recommending at all possibilities before starting.
Google itself states: "n addition to the standard frameworks and low- level datastore API, the Java SDK supports other frameworks designed to simplify datastore usage for Java developers. A large number of Java developers use these frameworks. The Google App Engine team highly recommends them and encourages you to check them out." in http://code.google.com/appengine/docs/java/datastore/overview.html#Introducing_the_Java_Datastore I personally abandonned JDO for Objectify months ago: it is efficient, simple to understand, much less opaque than JDO. Brings you the right level of abstraction: Objectify brings you back to comfortable abstraction level pojos (compared to the low-level api where every object is "torn in pieces") without all the complexity brought additionally by JDO/JPA. Up to you but as Steve said, study all the alternatives in line with your requirements before jumping in one direction. regards didier On Jan 28, 6:20 pm, Stephen Johnson <[email protected]> wrote: > Hi Matt, > There are several different ways to save/query objects from the datastore > not just JDO or JPA. They are: > 1. Low level api - work directly with the datastore's native (for lack of a > better term) representation of an object. > 2. JDO or JPA - work with these standards to abstract away the low-level api > and deal with the datastore in a more SQL like (loosely used here) way > 3. Use a third party framework like Objectify. > > Everyone has there comfort level that they want to work with. You can also > use more than one of these approaches in an application. I personally use > both JDO and the low-level api. I used JDO becuase when I started it was the > first thing I came across. Many have moved to 3rd party frameworks like > Objectify because unlike JDO which comes from the SQL world, Objectify is > geared toward the datastore and how it works and is a lighter framework. I > also use the low-level api mostly in my map reduce classes since that is how > you get the entities handed to you in the map function. > > The big point is not to get confused and using a mix of two of them and > thinking your doing the same one. I think from your number #1 and #2 that > you might be saving your entities using JDO and then trying to query with > the low-level api. Which is completely OK, but you have to understand how > the query mechanism and keys are represented in both formats. From a > learning perspective and really understand the datastore I would play around > with the low-level API before moving to one of the higher-level APIs > especially relationships between entities.. You probably will want to use a > higher level API in your actual production code, but understanding how keys, > queries, transactions, entity groups, relationships, indexes etc. work at > the low-level will make your life a lot easier in the long run. I wish I > would've started learning the low-level API first. > > Hope some of this helps, > Steve > > On Fri, Jan 28, 2011 at 10:06 AM, Matt Reeves <[email protected]> wrote: > > I'm a total n00b here and just getting started trying to figure out how the > > datastore works, mostly by reading the documentation. Here are the > > assumptions I am making, please tell me if I'm saying anything incorrect: > > > 1) To define persistent entities, one must either create persistent JDO > > classes as mentioned here (http://goo.gl/w9fno) or use JPA > > 2) Once data is loaded to the entities, the queries explained here ( > >http://goo.gl/lHO3S) are the best approach to take for querying the > > datastore as they will query any entity regardless of how it was defined. > > 3) The bulkloader tool can be used to upload data to an entity > > > So far, I have defined some entities using JDO classes, and then I used the > > bulkloader to upload data for the entities from a csv file. The data shows > > up when viewed from the admin console, but when I run the simple flavor of > > queries as mentioned in #2 above, I am getting no results. Any help or > > introductory advice would be much appreciated. Thanks. > > > Here is an example of a class I have defined: > > > @PersistenceCapable(identityType = IdentityType.APPLICATION) > > public class Rec { > > > @PrimaryKey > > @Persistent > > private String code; > > @Persistent > > private String name; > > @Persistent > > private Double value; > > > public String getCode() { > > return this.code; > > } > > public String getName() { > > return this.name; > > } > > public Double getValue() { > > return this.value; > > } > > } > > > And here is an example of the query I am trying, just trying to grab the > > stored data and populate new object for runtime: > > > Vector<Rec2> Rec2V = new Vector<Rec2>(); > > DatastoreService datastore = > > DatastoreServiceFactory.getDatastoreService(); > > Query q = new Query(Rec.class.getName()); > > q.addSort("value", Query.SortDirection.DESCENDING); > > PreparedQuery pq = datastore.prepare(q); > > for (Entity result : pq.asIterable()) { > > Rec2V.add(new Rec2( > > (String) result.getProperty("code"), > > (String) result.getProperty("name"), > > (Double) result.getProperty("value") > > )); > > } > > > -- > > 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%[email protected]> > > . > > 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 [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.
