You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating a virtual relationship using apoc.create.vRelationship can result in objects being returned from neo4j containing null values where the properties wouldn't be passed in a normal relationship. An example of this is if a property of the virtual relationship is being mapped from a node property that is null. Trying to retrieve these virtual relationships results in a null pointer exception being thrown.
Expected Behavior
Virtual relationship properties that are returned as null from an apoc.create.vRelationship call should be mapped to null
My current use case is trying to create virtual relationships to model data structures that require the use of intermediate nodes. For example I want to model the relationship (A)-[:r]->(B) except r also needs to reference (C). So in Neo4J I have modelled it as follows:
(A)-[:r1]->(R)-[:r2]-(B) and (R)-[:r3]->(C)
I don't want this complexity to be returned to the client so I create the virtual relationship as mentioned above, except if I am mapping properties from C to r and C does not exist they get mapped as null. This would be fine except for the null pointer exception issues mentioned.
Your Environment
Java version:
Neo4j version: 4.4.5
OGM Version: 3.2.35
OGM Transport used: Bolt
Neo4j Java Driver version (in case of Bolt transport): 4.3.6
Steps to Reproduce
Node
@NodeEntity
public class TestNode {
}
Relationship
@RelationshipEntity(type = "test_relationship")
public class TestRelationship {
@StartNode
TestNode startNode;
@EndNode
TestNode endNode;
private String testField;
}
When using stored procedures the transport of actual `null` properties in entities is possible and leads to a NPE. This changes checks for `NO_VALUE` respectively `NullValue` and filters literal `null` properties afterwards.
Closes#909.
Creating a virtual relationship using apoc.create.vRelationship can result in objects being returned from neo4j containing null values where the properties wouldn't be passed in a normal relationship. An example of this is if a property of the virtual relationship is being mapped from a node property that is null. Trying to retrieve these virtual relationships results in a null pointer exception being thrown.
Expected Behavior
Virtual relationship properties that are returned as null from an apoc.create.vRelationship call should be mapped to null
Current Behavior
Properties containing null values are mapped as objects of type NullValue and get transformed to null when the value.asObject() method is called in the toMapped method in BoltEntityAdapter - https://github.com/neo4j/neo4j-ogm/blob/master/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/driver/BoltEntityAdapter.java#L121
On the subsequent line object.getClass() is called, resulting in a null pointer exception - https://github.com/neo4j/neo4j-ogm/blob/master/bolt-driver/src/main/java/org/neo4j/ogm/drivers/bolt/driver/BoltEntityAdapter.java#L122
A simple null check on object after Object object = value.asObject() should solve this problem.
Context
My current use case is trying to create virtual relationships to model data structures that require the use of intermediate nodes. For example I want to model the relationship (A)-[:r]->(B) except r also needs to reference (C). So in Neo4J I have modelled it as follows:
(A)-[:r1]->(R)-[:r2]-(B) and (R)-[:r3]->(C)
I don't want this complexity to be returned to the client so I create the virtual relationship as mentioned above, except if I am mapping properties from C to r and C does not exist they get mapped as null. This would be fine except for the null pointer exception issues mentioned.
Your Environment
Steps to Reproduce
Node
Relationship
Repository
The text was updated successfully, but these errors were encountered: