Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-21-2020 01:15 AM
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 !
04-21-2020 02:43 AM
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.
All the sessions of the conference are now available online