Neo4j之四_Spring-Data-neo4j

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);

    }

你可能感兴趣的:(数据库之NoSQL,neo4j)