Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control depth on custom Spring Data Neo4j repository methods?

For example, if I want to get list of users by name:

class UserRepository extands GraphRepository<User> {

    List<User> findByName(String name);
}

then how to set loading depth to 2?

I tried to find answer in the SDN 4.0.0.RC2 docs, but it isn't contains anything about this issue.

like image 323
Victor Dombrovsky Avatar asked Aug 29 '15 14:08

Victor Dombrovsky


1 Answers

As of SDN 4.2.0-M1, this feature has been implemented. It hasn't made it to the reference documentation at the time of this writing, but see this PR for implementation, tests and example app updates.

In short, derived finder methods can now sport a @Depth(n) annotation to specify a fetch depth of n (ref). You can also add a @Depth-annotated argument to method signatures that can be used to specify the fetch depth on each call (ref).

Cheers, @Luanne - this looks great :)

like image 153
drew moore Avatar answered Oct 16 '22 10:10

drew moore