简体   繁体   English

Neo4j 创建节点

[英]Neo4j create node

I'm using repository which extends GraphRepository .我正在使用扩展GraphRepository存储库。 It is easy to do some queries or save nodes by derived methods, but is there any simply way to create node?通过派生的方法做一些查询或保存节点很容易,但是有没有简单的方法来创建节点? For example, for queries I can use repository.findAll() , to save it is repository.save() but why there is no method like repository.createNode() ?例如,对于查询,我可以使用repository.findAll()来保存它是repository.save()但是为什么没有像repository.createNode()这样的方法? If something like that doesn't exist, what is the easiest way to create node?如果这样的东西不存在,创建节点的最简单方法是什么?

A node is defined in Spring Data Neo4j (SDN) with the annotation @NodeEntity at the class level on a domain object (POJO).在 Spring Data Neo4j (SDN) 中定义了一个节点,在域对象 (POJO) 的类级别使用注解@NodeEntity A usual pattern then is for any domain objects that require persistence support you would create a Neo4jRepository or GraphRepository for them.通常的模式是对于需要持久性支持的任何域对象,您将为它们创建Neo4jRepositoryGraphRepository This way when you call repository.save(nodeEntity) you are actually saving the node itself.这样,当您调用repository.save(nodeEntity)您实际上是在保存节点本身。 Having another method like createNode() is therefore redundant.因此,使用另一种方法(如createNode()是多余的。

Remember, save() handles both creation and updating of nodes.请记住, save()处理节点的创建和更新。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM