cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Neo4j not mapping relationship

im having issue while trying to get node mapping in neo4j(spring boot) the problem is like this :

I have already node User created in DB now what Im doing is trying to create node Channel and create outgoing relationship CREATED_BY from Channel to User and I return both nodes and relationship but neo4j is not mapping relationship nor User entity here it's the code :

@NodeEntity
public class Channel {

    //... other properties including ID

    @Relationship(type = "CREATED_BY", direction = Relationship.OUTGOING)
    protected User creator;

    @Relationship(type = "CREATED_BY", direction = Relationship.OUTGOING)
    protected ChannelCreatorRelationship channelCreatorRelationship;

    //geters and setters

}

Cypher query to create and return nodes and relationships :

@Query("MATCH (u:User { userId:2 }) " +
            "MERGE (ch:Channel {name:'name'}) " +
            "MERGE (ch)-[r:CREATED_BY]->(u) " +
            "RETURN ch,r,u;")
    Optional<Channel> createChannel();

Response that Im getting is channel but with user node or relationship node as null :

{
  "name": "name",
  "creator": null,
  "channelCreatorRelationship": null
}

Thanks !

1 REPLY 1

Could it be the case that ChannelCreatorRelationship is a RelationshipEntity connecting Channel and User? This won't work because they both would describe the very same relationship and you should see a warning in the logs.