Wednesday, December 8, 2010

Updating my apps database schema in the App Engine's datastore

I had read this article by Mark Ivey:
http://code.google.com/appengine/articles/update_schema.html

So I thought I was ready for this ... but!!

I had added a new field like this:
@Persistent
private int sortorder;

And got this error whatever I did:
This property is mapped to FIELD, which cannot accept null values.

So I changed my field definition to:

@Persistent
private Integer sortorder;

Now I could loop the records in my table and assign default values, because now null is accepted!

Puh ...

2 comments:

Anonymous said...

You got this error :
"This property is mapped to FIELD,"

It is because "int" :

@Persistent
private int sortorder;


is a primitive data type and thus cannot point to a null values,
whereas "Integer" :


@Persistent
private Integer sortorder;


is an Object and only objects (i.e String,Integer,Double etc..) can point to a null reference.

Hope that helps.

Ramon

fredpallesen said...

well yes I did get that - but the problem is that in the when I go to the Dashboard in app engine and try the Datastore viewer - I will get a "Server Error -
A server error has occurred."
after an update with int's it class.