[cypher] Help with query to recurse parent relationship

17 views
Skip to first unread message

Reaves, Timothy

unread,
Oct 3, 2012, 11:40:13 AM10/3/12
to ne...@googlegroups.com
I have two classes such:
@NodeEntity
public class A implements Comparable<A>{
   @GraphId Long nodeId;
   @Indexed String name;
   @RelatedTo(type="MEMBERS") Set<B> b_collection;
   @RelatedTo(type="PARENT_OF") Set<A> children;
   @Fetch @RelatedTo(type="PARENT_OF", direction=Direction.INCOMING) A parent;
}
@NodeEntity
public class B {
   @GraphId protected Long nodeId;
   @Indexed(level = Indexed.Level.GLOBAL) String hash;
   @Indexed(level = Indexed.Level.INSTANCE) String name;
   @RelatedTo(type="MEMBERS", direction = Direction.INCOMING) Set<A> a_collection;
}
I have a repository method:
B findByAsNameAndHash(String aName, String hash);

This method works fine. It finds the instance of B with a given hash, as long as it is in the b_collection of an instance of A with the given name.

What I would like is a second method that does the same, except it would also look in the b_collection of not only the A instance with the given name, but all A related to the matched A via the parent attribute. Effectively, what I want is to find the given A, create a union set of b_collection with all those up the parent hierarchy, then find the matching B in that union set, if it exists.

Is this possible?
Reply all
Reply to author
Forward
0 new messages