Spring – Neo4j : Class Attribute return Null when there is Relationship Entity

By | July 12, 2018
Questions:

I have 3 classes created on my Spring Project. Class A, B and C. Class A and C is Independent Node. Class B is RelationshipEntity of Class A-C.

@NodeEntity
public class A {
    @GraphId
    private Long graphId;

    private String id;

    @Relationship(type = "a_has_c", direction = "INCOMING")
    private C cData;

    public A() {
        super();
    }
}

@RelationshipEntity(type="a_has_c")
public class B {
    @GraphId
    private Long graphId;

    private String id;

    @StartNode
    private A a;

    @EndNode
    private C c;

    public B() {
        super();
    }
}

@NodeEntity
public class C {
    @GraphId
    private Long graphId;

    private String id;

    public C() {
        super();
    }
}

The problem is, before I create @RelationshipEntity Node, I can retrieve information of cData from attribute on Class A. But after I have created @RelationshipEntity, it always return Null.

Do I need to always fetch 2 times if I want to get information of cData from attribute at class A?

I am using Spring Boot 1.5.6 Release and Neo4j Community 3.0.6

Answers:

Leave a Reply

Your email address will not be published. Required fields are marked *