有谁知道如何在 AppEngine 实体中保存一个简单的数字数组?
例如,如果我有这个类的对象:
class Person {
String name;
Date dateOfBirth;
int favoriteNumbers[];
Person(String name, Date dateOfBirth, int[] favoriteNumbers) {
this.name = name;
this.dateOfBirth = dateOfBirth;
this.favoriteNumbers = favoriteNumbers;
}
}
//save the entity !
Person person = new Person("Jack", new Date(), new int[]{2, 3, 4});
Entity entity = new Entity("person");
entity.setProperty("name", person.name);
entity.setProperty("dateOfBirth",person.dateOfBirth);
entity.setProperty("favoriteNumbers",favoriteNumbers);// this here thrown an exception !
java.lang.IllegalArgumentException: firsRound: [I is not a supported property type.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue(DataTypeUtils.java:235)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:207)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:173)
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedValue(DataTypeUtils.java:148)
at com.google.appengine.api.datastore.PropertyContainer.setProperty(PropertyContainer.java:101)
.......
*注:以上代码与真实代码相似。为简单起见,我提供了此代码。*