I am using a Goole application datastore with Java and trying to load an object with an enumeration list. Each time I load an object, List is NULL. An object
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ObjectToSave {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private List<AnEnum> anEnumList;
}
The listing is simple
public enum AnEnum {
VALUE_1,
VALUE_2;
}
Code to save
ObjectToSave objectToSave = new ObjectToSave();
List<AnEnum> anEnumList = new ArrayList<AnEnum>();
anEnumList.add(AnEnum.VALUE_1);
objectToSave.setAnEnumList(anEnumList);
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
pm.makePersistent(objectToSave);
} finally {
pm.close();
}
Download Code -
PersistenceManager pm = pmfInstance.getPersistenceManager();
try {
Key key = KeyFactory.createKey(ObjectToSave.class.getSimpleName(), id);
ObjectToSave objectToSave = pm.getObjectById(ObjectToSave.class, key);
} finally {
pm.close();
}
I can view the data in the data warehouse using http: // localhost: 8080 / _ah / admin and see that my list is saved, but it does not exist when the object is loaded.
I created my project with the Eclipse plugin and did not make any changes to the data warehouse settings, as far as I know. So why id my Enum list null?
Chris source
share