I have defined simple one-to-many relationship as:
@Relationship(type = "BELONG")
private Set<Category> categories;
I want to query all the objects based on the exact set of Category
. i.e. implement something like:
Page<SomeObject> findAllByCategories(Set<Category> categories, PageRequest page);
What is the best way to do it in Spring Data Neo4j?
You have a couple of options on how you can do this.
Your calling code can simply call the following on your
SomeObjectRepository
:Note this method does not support paging though.
Another way is to inject a
Session
into your calling code and either write a custom Cypher query to retrieve the objects you want or use the load all by instance method:My recommendation would be option 2 as it pretty much does exactly what you want.