Hi All
I've started building some Java project based on the neo4j graph and came across an annoying issue.
The project is configured to use both org.springframework.boot:spring-boot-starter-data-neo4j and org.springframework.data:spring-data-neo4j artifacts (is that ok?)
I have this simple graph: a User is a MEMBER_OF a Group. The MemberOf has a property membershipType. So on the project there are 2 @Node and one @RelationshipProperties classes.
I can easily fetch this by querying:
MATCH (g:Group) <-[m:MEMBER_OF]- (u:User) where u.authId = '123456789123456789' RETURN g,u
The main issue I'm having is on fetching relationship data using spring data neo4j.
I'm trying two different methods and only one of them works.
public interface GroupRepository extends CrudRepository<Group, String> {
..
// #1
List<Group> findAllByMembersUserAuthId(String authId);
// #2
@Query("MATCH (g:Group) <-[m:MEMBER_OF]- (u:User) where u.authId = $authId RETURN g,u")
List<Group> getByUserAuthId(String authId);
}
When using #1 it's working well and I can see the nice hierarchy of Group->members->User, but when using #2 the members object remains null:
I played with this a lot and got to a point that members list did have one object, with the membershipType property populated but the TargetNode (User) was still null.
Would really appreciate some help here.
Thanks
Koby