views:

34

answers:

1

So if I have a class of which I have a number saved in a datastore, and then seek to add a field later, how can I prevent all my previous objects breaking? Is there a way to retroactively set those fields so they're not null?

I'm using JDO.

A: 

It depends on how you are accessing the datastore. Which runtime (python/java) and which API are you using to access the datastore? The datastore itself is schemaless, so it dosen't care what is or isn't in a certain entity. On the Java side, if you use the low level datastore API, you wouldn't have any problems accessing the "old" entities and adding in the data you want to. However, if you are using JDO or JPA to access the datastore, you might get errors accessing the entities with missing data.

Peter Recore
Java. I'm using JDO. I get null pointer exceptions on old entities if I add a new field.
Joren
right. that's why you need to use the low level datastore API. You'll notice I said you might get errors if you tried to use JDO to do this :)
Peter Recore