Neo4j OGM 2.0查询路径

时间:2016-02-09 13:52:36

标签: java neo4j neo4j-ogm

我正在尝试执行返回路径的查询,但是,虽然在 Dim emailBody As String ' At the very minimum your basic HTML page is made up of: ' <html> ' <body> ' Your message, including any formatting or hyperlniks. ' </body> ' </html> ' emailBody = "<html><body><font face=""Arial, sans-serif"">" emailBody = emailBody & "Dear User, New Submittal " emailBody = emailBody & "<a href=""" & SubmitLink & """>" & SubmitLink & "</a>" emailBody = emailBody & " has been Added in submittal Log. Please Investigate the Change<br><br><br>Sincerely," emailBody = emailBody & "</font></body></html>" newmsg.HTMLBody = emailBody 中执行的相同查询会返回正确的结果,但neo4j Web UI会返回neo4j-ogm。我已经从Maven安装了null

我的java代码如下:

Root.java:

neo4j-ogm-api,core:2.0.0-M01

Leaf.java:

@NodeEntity
public class Root
{
    @GraphId
    public Long id;

    @Relationship(type = "Branch", direction = Relationship.OOUTGOING)
    public List<Branch> branches = new ArrayList<>();

    public Branch addLeaf(Leaf leaf, float length)
    {
        Branch b = new Branch(this, leaf);
        b.length = length;
        leaf.branch = b;
        branches.add(b); 
        return b;           
    }
}

Branch.java:

@NodeEntity
public class Leaf
{
    @GraphId
    public Long id;

    @Property
    public String color;

    @Relationship(type = "Branch", direction = Relationship.INCOMING)
    public Branch branch;
}

然后,为了进行测试,我们来做

@RelationshipEntity
public class Branch
{        
    @GraphId
    public Long id;

    public Branch(Root root, Leaf leaf)
    {
        this.root = root;
        this.leaf = leaf;
    }

    @Property
    public float length;

    @StartNode
    public Root root;

    @EndNode
    public Leaf leaf;
}

请告诉我,我做错了什么?

1 个答案:

答案 0 :(得分:1)

不支持返回完整路径。相反,您需要将要映射的节点和关系返回到域实体,例如:

MATCH path = (l1:Leaf)-[*1..100]-(l2:Leaf) WITH path,l1 LIMIT 1 RETURN l1,nodes(path),rels(path)

这将为您提供org.neo4j.ogm.session.Result个对象。如果从底层Map中检索l1,则应该有一个完全水合的Leaf实体。

BTW不确定QueryResultModel是什么 - 只在SDN中支持QueryResult。