在neo4j中,我们可以使用来添加具有各种属性的节点和关系
node.setProperty("NodePropertyName",NodePropertyValue)
relationship.setProperty("EdgePropertyName",EdgePropertyValue)
有什么方法可以使用非原始数据类型(如MAP,Array或用户定义的对象)作为
NodePropertyValue
和EdgePropertyValue
?还是我需要单独给出
MAP<>
中的所有值作为Node
或Relationship
的单独属性?我尝试使用
node.setProperty("USER_PROPERTIES", GraphNode.getNodeproperties());
where,
GraphNode.getNodeproperties() returns MAP<String,Double>
但这给我一个错误:
java.lang.IllegalArgumentException: Unknown property type on: {Property1=0.0, Property2=0.0, Property3=0.0, Property4=0.0, Property5=0.0, Property6=0.0, Property7=0.0}
最佳答案
有什么方法可以使用MAP这样的非原始数据类型,
数组或用户定义的对象为NodePropertyValue和
EdgePropertyValue?
Neo4J允许您存储String
数组或原始数据类型的数组。
目前尚不支持地图,但是一种替代方法是将地图存储为JSON结构(使用GSON或Jackson),或者甚至存储为XML结构(使用XStream)。