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 !