cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 2: migrate recent content

OGM SDN 6 query by relationship property

richard_skallos
Node Link

Is there a way to use findBy.. to retrieve a subset of a graph model based on a relationship property value?
Example: Given nodes A, B. A is related to node B by R. R has a r.type property. The following model classes exist. A and B are @Node classes and R is a @RelationshipProperties class.

Can I complete a List<A> findByType( String Type) or does the parameter need to be found in the specified model class, A.

Maybe the only way to accomplish this is using a custom query. Then map all the data to model or DTO classes.

1 REPLY 1

gerrit_meier
Neo4j
Neo4j

Yes, this is possible. You would do this just like any other property based query.

class A {
   List<R> relatedThings;
}

You would define a findByRelatedThingsType(String type) finder method to query for the r.type property in a Neo4jRepository<A,...>.