Empty list in appengine datastore: java vs python

Posted by lOranger on Stack Overflow See other posts from Stack Overflow or by lOranger
Published on 2010-02-22T14:40:16Z Indexed on 2010/04/18 19:03 UTC
Read the original article Hit count: 396

I have the following java model class in AppEngine:

public class Xyz ... {
    @Persistent
    private Set<Long> uvw;
}

When saving an object Xyz with an empty set uvw in Java, I get a "null" field (as listed in the appengine datastore viewer). When I try to load the same object in python (through remote_api), as defined by the following python model class:

class Xys(db.Model):
    uvw = db.ListProperty(int)

I get a "BadValueError: Property uvw is required".

When saving another object of the same class in python with an empty uvw list, the datastore viewer print a "missing" field.

Apparently empty lists storage handling differs between Java and python and lead to "incompatible" objects.

Thus my question: Is there a way to, either:

  • force Java to store an empty list as a "missing" field,
  • force Python to gracefully accept a "null" list as an empty list when loading the object?

Or any other suggestion on how to handle empty list field in both languages.

Thanks for your answers!

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about java