我正在使用 Neo4J OGM(最新版本)将我的数据序列化到 Neo4J 嵌入式数据库中。
这适用于我的大多数实体,但是一旦我尝试保存树状结构,就需要永远保存并且似乎创建了数千个这样的关系,尽管我只是保存了一些节点:
RequestExecutor: 223 - creating new node id: -32715, 14690, [255, 100, 139, 207]
RequestExecutor: 223 - creating new node id: -32718, 14691, [29, 95]
RequestExecutor: 223 - creating new node id: -32721, 14692, [255, 102, 142, 212]
RequestExecutor: 223 - creating new node id: -32724, 14693, [30, 95]
RequestExecutor: 223 - creating new node id: -32727, 14694, [255, 103, 143, 213]
RequestExecutor: 223 - creating new node id: -32730, 14695, [31, 95]
RequestExecutor: 223 - creating new node id: -32733, 14696, [255, 103, 143, 213]
RequestExecutor: 223 - creating new node id: -32736, 14697, [32, 95]
这些展开操作也需要很长时间(这一行要长得多,只是摘录):
EmbeddedRequest: 152 - Request: UNWIND {rows} as row MATCH (startNode) WHERE ID(startNode) = row.startNodeId WITH row,startNode MATCH (endNode) WHERE ID(endNode) = row.endNodeId MERGE (startNode)-[rel:`hasParentNd`]->(endNode) RETURN row.relRef as ref, ID(rel) as id, {type} as type with params {type=rel, rows=[{startNodeId=33, relRef=-32770, endNodeId=32, props={}}, {startNodeId=34, relRef=-32773, endNodeId=61, props={}}, {startNodeId=35, relRef=-32776, endNodeId=34, props={}}, {startNodeId=36, relRef=-32779, endNodeId=61, props={}}, {startNodeId=37, relRef=-32782, endNodeId=36, props={}}, {startNodeId=38, relRef=-32785, endNodeId=61, props={}}, {startNodeId=39, relRef=-19, endNodeId=14698, props={}}, {startNodeId=40, relRef=-32788, endNodeId=38, props={}}, {startNodeId=41, relRef=-22, endNodeId=39, props={}}, {startNodeId=42, relRef=-32791, endNodeId=61, props={}}, {startNodeId=43, relRef=-25, endNodeId=41,......
节点本身看起来像这样。NeoEntity 类拥有唯一的 id。
@NodeEntity
public class NeoNode extends NeoEntity implements Node, Node.Op {
@Property("unique")
private boolean unique = true;
@Relationship(type = "hasChildrenNd", direction = Relationship.INCOMING)
private ArrayList<NeoNode.Op> children = new ArrayList<>();
@Transient
private NeoArtifact.Op<?> artifact;
@Relationship(type = "hasParentNd")
private Op parent;
public NeoNode() {}
...
}
我尝试过各种关系,但都没有找到解决办法。将非常感谢任何想法。
附加信息:如果我让它运行,它会填满堆直到它崩溃:
Exception in thread "neo4j.Scheduler-1" Exception in thread "Neo4j UDC Timer" java.lang.OutOfMemoryError: Java heap space