Nick, What's likely happening here is that the fields you need are being lazily loaded. Properties that aren't indexed like Text or Blobs are retrieved when you call the appropriate getter. For instance, if I have a model Car with a Text Description field, I would have to do this:
// How to get a null Description PersistenceManager pm = PMF.get().getPersistenceManager(); Car car = pm.getObjectById(Car.class, someId); pm.close(); car.getDescription(); // This is NULL // How to get a description PersistenceManager pm = PMF.get().getPersistenceManager(); Car car = pm.getObjectById(Car.class, someId); car.getDescription(); pm.close(); car.getDescription(); // This is not NULL Can you try retrieving the embedded class before checking for a value? Your debugger will list it as NULL, but if you have a debugger that has "evaluate in context" capability, you can call the getter and check the object again. The field will appear populated. We did this originally to follow the JDO spec, however, we've received feedback that it's confusing to the majority of our developers, so we'll be changing this behavior to load all fields eagerly. We'll document this so that JDO veterans will be aware of this behavior. On Sun, Nov 15, 2009 at 8:32 PM, Nick Bonatsakis <[email protected]>wrote: > Hi All, > > I have followed the instructions on how to create the appropriate > classes for JUnit testing and have a fairly simple object hierarchy. I > have one class that includes a few embedded objects, they are all > correctly annotated with JDO annotations (i have compared them > directly to the example jdo classes that ship with GAE). I create an > instance of the parent object, set all the fields including the > embedded ones, then used the PersistenceManager to make the instance > persisted. When i query for all instances of the class, I get back the > right number of instances, the non-embedded fields are there, but all > of the embedded fields have null values. > > I also tried writing a simple test using the AddressBookEntry class, > and see the same behavior when looking in the debugger, that code is > as follows: > > @Test > public void testAddy(){ > > AddressBookUtils.insertNew > ("John","Doe","Hart","CT","8448445"); > > PersistenceManager pm = PMF.get().getPersistenceManager(); > Query q = pm.newQuery(AddressBookEntry.class); > List l = (List) q.execute(); > } > > Anyone have any pointers on how to resolve this? > > Thanks! > > -- > > 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=. > > > -- Ikai Lan Developer Programs Engineer, Google App Engine -- 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=.
