A datastore property can have more than one value. In Slim3 Datastore, this is represented by a single field with a Collection type, where the collection is of one of the core value types or a Serializable class. The following Collection types are supported:

  • java.util.ArrayList<...>
  • java.util.LinkedList<...>
  • java.util.HashSet<...>
  • java.util.LinkedHashSet<...>
  • java.util.TreeSet<...>
  • java.util.List<...>
  • java.util.Set<...>
  • java.util.SortedSet<...>

If a field is declared as a List, objects returned by Slim3 Datastore will have an ArrayList value. If a field is declared as a Set, Slim3 Datastore returns a HashSet. If a field is declared as a SortedSet, Slim3 Datastore returns a TreeSet.

Collection values are indexed and can be used in query filters or sort orders.

For example, a field whose type is List<String> is stored as zero or more string values for the property, one for each value in the List.

import java.util.List;

// ...

List<String> favoriteFoods;

// ... accessors ...

An array is not supported as Collection. This means array values are not indexed and cannot be used in query filters or sort orders. If you want to store arrays in the datastore, you should specified the field as a Serializable class.

import org.slim3.datastore.Attribute;

// ...

@Attribute(lob = true)
private String[] favoriteFoods;

// ... accessors ...


Continue to Unindexed Properties.