IHow do I print child records? I have 3 parent enitities with each of
the parents having 2 - 5 children. I'm trying to print the parent
list, then then each of the child grouped by parent sequentially,
i.e.,
parent1.name, parent2.name, parent3.name
parent1.childname, parent1.childname
parent2.childname, parent2.childname, parent2.childname
parent3.childname
I thought the below might work, but while I can get the parents, I can
seem to find no way to get the children. Thanks for your patience and
answer. Best.
def query = new Query("parent")
query.addSort("order", Query.SortDirection.ASCENDING)
PreparedQuery preparedQuery = datastore.prepare(query)
def parent = preparedQuery.asList(withLimit(10))
parent.each { Entity entity ->
print entity.name
}
parent.each { Entity entity ->
def query_child = new Query("child")
query_child.addSort("order", Query.SortDirection.ASCENDING)
query_child.addFilter("parent", Query.FilterOperator.EQUAL,
entity.title)
PreparedQuery preparedQuery = datastore.prepare(query_child)
def child = preparedQuery.asList(withLimit(10))
child.each { Entity entity ->
print sub_nav.name
}
}
--
You received this message because you are subscribed to the Google Groups
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine-java?hl=en.