Hello all. Newbie ( to Objectify4 ) here. Objectify4 rocks!
Trying to do a 1-to-many using Colleciton of @Embed's. Got the general idea from another post in this group.
However, my @Embed class contains it's own collection. ( using Objectify4.0a4 )
@Entity
class Group {
@Id
Long id;
@Embed
static class GroupPerson {
@Index
@Load
public Ref<Person> person;
public Set<String> roles; // <---- collection inside @Embed object
}
static class GroupPersonMapper implements Mapper< Key<Person> , GroupPerson > {
@Override
public Key<Person> getKey(GroupPerson value) {
return value.person.getKey();
}
}
@Mapify(GroupPersonMapper.class)
@Load
Map< Key<Person> , GroupPerson > groupMembers; // <-- collection of @Embed objects
}
I can persist this to the dataStore fine, and it even looks "right" in the GAE console.
groupMembers.roles = [role1,role2] (unindexed)
When i tried to load a Group entity (from a Query), I get the following exception
com.googlecode.objectify.LoadException: Error loading Group(2155): groupMembers.roles: Expected list structure but found {role1,role2}
at com.googlecode.objectify.impl.Transmog.load(Transmog.java:76)
at com.googlecode.objectify.impl.ConcreteEntityMetadata.load(ConcreteEntityMetadata.java:121)
at com.googlecode.objectify.impl.cmd.ObjectifyImpl.load(ObjectifyImpl.java:386)
at com.googlecode.objectify.impl.engine.LoadEngine$Round$2.now(LoadEngine.java:102)
at com.googlecode.objectify.impl.ref.StdRef.get(StdRef.java:57)
at com.googlecode.objectify.impl.cmd.QueryImpl$3.translate(QueryImpl.java:381)
at com.googlecode.objectify.impl.cmd.QueryImpl$3.translate(QueryImpl.java:1)
at com.googlecode.objectify.util.TranslatingQueryResultIterable$1.translate(TranslatingQueryResultIterable.java:31)
at com.googlecode.objectify.util.TranslatingIterator.next(TranslatingIterator.java:35)
Changing Collection from Set<String> to List<String> had no effect. Should this work? Am I doing something wrong?
Thanks in advance,
Andy