Yes I completely understand why Google Datastore would return nulls. Why doesn't the Datanucleus code handle the nulls appropriately? Datanucleus knows that the object has a primitive, and just take the less robust approach. It could check to see if it is a primitive and check to see if the value is null, if value is null, set to default value.
Right now Datanucleus doesn't allow you to add a new field that is a primitive. If you want to add a field it must be a Object form. --Jeff On Thu, Dec 31, 2009 at 10:46 AM, Rusty Wright <rwright.li...@gmail.com>wrote: > I forgot to add that missing fields are always (I think) returned as null > by the datastore. > > > Rusty Wright wrote: > > It's the GAE datastore. When you add a new field, say an int, it uses > > null for the missing field in the datastore, then when it tries to unbox > > it; i.e., ((Integer) null).intValue() you get the NPE. > > > > > > Jeffrey Goetsch wrote: > >> Why do I get a NullPointerException when I add a new primitive field > >> to an object? Why doesn't JDO just recognize that it is a primitive > >> and leave the default value? > >> > >> Thanks, > >> --Jeff > >> > >> -- > >> > >> 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<google-appengine-java%2bunsubscr...@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<google-appengine-java%2bunsubscr...@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.