1
votes

Does anyone know if GAE Datastore API supports user made classes and\or collections (e.g ArrayList etc)?

I have the following code line:

entity.setProperty("offlineUsers",user._network._offlineUsers);

Where the property type is an ArrayList of a 'User' class I created . This line of code threw the following exception :

java.lang.IllegalArgumentException: offlineUsers: com.example.computeroom.User is not a supported property type.

So reading the datastore guide http://code.google.com/intl/iw/appengine/docs/java/datastore/entities.html raises my suspicion that you cannot store classes you created , or collections/arrays - I can only see support for basic types (int,boolean etc) and no mention of user defined objects or arrays\collections.

1- Just to be sure - is it true or not that the datastore has no support for user classes?

2- What about collections/arrays - can it really be that there's no support for arrays ?
How am I supposed to store large lists of users/data ?

4

4 Answers

1
votes

""Entities have named properties, the values of which may be basic types or collections of basic types. Richer objects, of course, may be stored if serialized as byte arrays, although that may prevent effective querying by those properties. "

It seems you can only store lists of basic type in datastore api.

1
votes

If you use Objectify, JPA or JDO, you will be able to store your own custom types.

http://objectify-appengine.googlecode.com/

0
votes

You can definitely store lists - any Collection I think. You can search within the lists after they're stored, but there are some unexpected limitations and behaviors.

You can store any user-defined class that you can serialize into bytes, of course, but you won't be able to index them to search on their members or anything.

0
votes

i'm not sure whether it answers your question.. Some where while reading queries and indexes page i saw this

dataStore.put(Arrays.asList(person, weddingPhoto, babyPhoto, dancePhoto,    campingPhoto));