6

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.

Luanne
  • 19,145
  • 1
  • 39
  • 51
Victor Dombrovsky
  • 2,955
  • 3
  • 21
  • 33

2 Answers2

11

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 :)

drew moore
  • 31,565
  • 17
  • 75
  • 112
10

Derived finders do not yet support a depth. You'll have to write a custom query or use the loadAllByProperty method on the Neo4jTemplate if applicable.

This should have been mentioned in the docs, we'll add it.

Luanne
  • 19,145
  • 1
  • 39
  • 51
  • 2
    It's a pity. In any case, many thanks for the explanation! Can you also clarify whether will it be supported in future or not? – Victor Dombrovsky Aug 29 '15 at 16:23
  • Yes, it will be, but I cannot say which release. You can track the issue here https://jira.spring.io/browse/DATAGRAPH-744 – Luanne Aug 31 '15 at 03:42