Using Collections
Morphia supports collections (List, Set, Map) and arrays (Integer).
...
private Set<String> tags;
private Map<String,Translation> translations;
@Reference
private List<Article> relatedArticles;
...
Morphia will use the following implementations (by default) when creating collections:
- java.util.ArrayList for List
- java.util.HashSet for Set
- java.util.HashMap for Map
If you want to use another implementation, you can override this on the annotations:
...
@Property(concreteClass = java.util.TreeSet.class)
private Set<String> tags;
@Embedded(concreteClass = java.util.TreeMap.class)
private Map<String,Translation> translations;
@Reference(concreteClass = java.util.Vector.class)
private List<Article> relatedArticles;
...