Neo4j之四_Spring-Data-neo4j

IMchg發表於2020-12-22

RelationshipEntity對應的Repository的save方法:若startNode、endNode不存在會先建立node,再建立邊;若node存在,則直接建立邊。

    @Test
    public void creatEdge(){
        com.weibo.propagate.pojo.neo4j.Blog blog1=new com.weibo.propagate.pojo.neo4j.Blog();
        blog1.setMid("a");
//        this.blogMapperNeo.save(blog1);

        com.weibo.propagate.pojo.neo4j.Blog blog2=new com.weibo.propagate.pojo.neo4j.Blog();
        blog1.setMid("b");
//        this.blogMapperNeo.save(blog2);

        BlogRelation blogRelation = new BlogRelation();
        blogRelation.setStartNode(blog1);
        blogRelation.setEndNode(blog2);
        this.blogRelationMapper.save(blogRelation);

    }

相關文章