I have a graph similar to this:
(t:Teacher)-[:TEACHES]-(s:Student)-[:ATTENDS]-(s:Subject)-[:REQUIRES]-(b:Book)
expressed in @NodeEntity
classes.
I need to load all @NodeEntities
for teachers with Ids withing a given range, and fetch all students taught by them, with their Subjects and the Books required by each Subject, all in one query.
I tried
int depth=3;
List<Long> ids = newArrayList(3,4,5);
session.loadAll(Teacher.class, ids, depth);
I actually started with the corresponding GraphRepository
findAll
it is the same thing.
Unfortunately I get a list of all available Teachers in the database, because each student happens to be taught by all teachers. I also tried running a custom @Query though it appears that you cannot specify custom depth How to control depth on custom Spring Data Neo4j repository methods? nor return more than one node from custom cypher query.
Do you have an idea why my approach is wrong? This seams to be a simple use of neo4j and I'm stuck with fetching my whole graph.