Tom Fishman
Tom Fishman

Reputation: 1826

How to store indexable list/collection in an appengine entity?

After creating an entity:

DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Entity employee = new Entity("Employee");

How to set an index-able list property? like say:

employee.setProperty("tag", "manager", "corrupted", ...);
//  "tag" is the property name, 
//  "manager", "corrupted".. are the values in the list.

Upvotes: 0

Views: 266

Answers (1)

Gary
Gary

Reputation: 916

Looking at the javadoc, you can give a Collection as the second param to setProperty.

E.g

List<String> tags = new ArrayList<String>();
tags.add("manager");
tags.add("corrupted");

employee.setProperty("tag", tags);

Upvotes: 1

Related Questions