1
votes

I'm using appengine and datastore. I have two GAE modules sharing the same data. One module is running on the Java runtime and utilizes objectify to write data. The other runs on the Python runtime and is using NDB for data read.

One of my kinds contains a list of embedded entities. When I try to fetch entities from this kind (Python module) the following error is raised:

RuntimeError: StructuredProperty memberOf expected to find properties separated by periods at a depth of 1; received ['memberOf']

Here is how the Java/objectify mapping looks like:

@Entity
public class Person {

    @Id
    private String id;

    @Unindex
    private Set<TeamMembership> memberOf = new HashSet<>();

    public static class TeamMembership {
        private DateTime joinedOn;
        private Ref<Team> team;

        private TeamMembership() {
        }
    }

}

Here is the respective Python NDB mapping:

class Person(ndb.Model):
    memberOf = ndb.StructuredProperty(TeamMembership, indexed=False, repeated=True)


class TeamMembership(ndb.Model):
    joinedOn = ndb.DateTimeProperty(indexed=False)
    team = ndb.KeyProperty(kind='Team', indexed=False, repeated=False)
1

1 Answers

2
votes

Try LocalStructuredProperty. NDB supports two ways of structuring data; LocalStructuredProperty corresponds to the java native EmbeddedEntity structure and works nicely.

The StructuredProperty format is a complicated beast that Objectify deprecated in v4.1 and abandoned entirely in v5.